Answers.Body: <p>You have a few overlapping topics here:</p>
  <ol>
  <li>Fitting a model to your data in Python</li>
  <li>Storing model parameters to the database</li>
  <li>Executing SQL queries to apply the model</li>
  </ol>
  <p>I would start with a linear model, such as <a href="https://en.wikipedia.org/wiki/Logistic_regression" rel="nofollow noreferrer">logistic regression</a> or <a href="https://en.wikipedia.org/wiki/Linear_discriminant_analysis" rel="nofollow noreferrer">linear discriminant analysis</a>.</p>
  <p>You should think carefully how you structure the data in the database. This is more of a programming topic, but I would have a table with few columns and several rows to represent each item. This way you don't need to modify the schema if your data gets a new input feature.</p>
  <p>Then as a final step you'll need to &quot;just&quot; write the SQL query, joining attribute data and model parameters and output. But this is off-topic on an AI forum.</p>
  <p>Getting back to linear regression, you must re-arrange the binary representations into separate columns:</p>
  <pre><code>array([[1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0],
         [0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0],
         [1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0],
         [1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1],
         [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],
         [1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1]])
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-25T13:58:46.357Z
Answers.LastActivityDate: 2022-10-25T13:58:46.357Z
Answers.UserDisplayName: NikoNyrh
Body: <p>What is the easiest classification algorithm in SQL when my data looks like this?</p>
  <pre><code>A = 101000101110
  B = 010101110010
  C = 100101101000
  B = 100101101101
  C = 100010000001
  A = 100010010101
  </code></pre>
  <p>These are binary vectors that indicate the presence of a certain attribute.</p>
  <p>I was thinking about training some kind of regression using python that gives me a vector.</p>
  <p>Then I would only need to multiple the vector with the binary vectors and I would bet some number indicating me what kind of label I have using a threshold method.</p>
  <p>Are there any python algorithms that allow me to do that?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-24T20:01:04.803Z
Comments.Text: Unless SQL has changed in the last 10 years and I missed it, SQL doesn't have machine learning algorithms... It's a language for specifying a query out of a database.  I suspect you might need to reword your question
Comments.UserDisplayName: David Hoelzer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-10-24T23:32:04.320Z
Comments.Text: The question, the data, and the goal are all unclear to me.  @Ohumeronen, please review this article on "How do I ask a good question?" and revise your post accordingly:  https://ai.stackexchange.com/help/how-to-ask.  You are more likely to get the help you need if you help us help you.
Comments.UserDisplayName: Snehal Patel
Tags: <machine-learning><python><linear-regression>
Title: SQL Machine Learning using matrix multiplication
UserDisplayName: Ohumeronen
ThreadText: # SQL Machine Learning using matrix multiplication
  
  (Asked by: username_0 on 2022-10-24)
  
  What is the easiest classification algorithm in SQL when my data looks like this?
  A = 101000101110
  B = 010101110010
  C = 100101101000
  B = 100101101101
  C = 100010000001
  A = 100010010101
  
  These are binary vectors that indicate the presence of a certain attribute.
  I was thinking about training some kind of regression using python that gives me a vector.
  Then I would only need to multiple the vector with the binary vectors and I would bet some number indicating me what kind of label I have using a threshold method.
  Are there any python algorithms that allow me to do that?
  
  **Tags:** machine-learning, python, linear-regression
  > **Comments:**
  > **username_1**: Unless SQL has changed in the last 10 years and I missed it, SQL doesn't have machine learning algorithms... It's a language for specifying a query out of a database.  I suspect you might need to reword your question  
  > **username_2**: The question, the data, and the goal are all unclear to me.  @Ohumeronen, please review this article on "How do I ask a good question?" and revise your post accordingly:  https://ai.stackexchange.com/help/how-to-ask.  You are more likely to get the help you need if you help us help you.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2022-10-25. Score: 1
  
  You have a few overlapping topics here:
  
  Fitting a model to your data in Python
  Storing model parameters to the database
  Executing SQL queries to apply the model
  
  I would start with a linear model, such as logistic regression or linear discriminant analysis.
  You should think carefully how you structure the data in the database. This is more of a programming topic, but I would have a table with few columns and several rows to represent each item. This way you don't need to modify the schema if your data gets a new input feature.
  Then as a final step you'll need to "just" write the SQL query, joining attribute data and model parameters and output. But this is off-topic on an AI forum.
  Getting back to linear regression, you must re-arrange the binary representations into separate columns:
  array([[1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0],
         [0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0],
         [1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0],
         [1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1],
         [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],
         [1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1]])
  
  
  ---
  
  