-1
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ 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 $\endgroup$ Oct 24, 2022 at 20:01
  • $\begingroup$ 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: ai.stackexchange.com/help/how-to-ask. You are more likely to get the help you need if you help us help you. $\endgroup$ Oct 24, 2022 at 23:32

1 Answer 1

1
$\begingroup$

You have a few overlapping topics here:

  1. Fitting a model to your data in Python
  2. Storing model parameters to the database
  3. 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]])
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .