Creating data set to sklearn with dataframe pandas

1

I have the following situation

from sklearn.linear_model import LogisticRegression
import pandas as pd

x = pd.DataFrame({'A':[1,3,8,6,1],'B':[2,6,9,3,2]})
y = pd.DataFrame({'C':[8,6,3,6,1]})

How do I make this happen?

LogisticRegression( ).fit(x, y)

I have the following answer:

ValueError: Unknown label type: array([8,6,3,6,1]) #valores do y

What is the right way?

    
asked by anonymous 01.07.2016 / 19:02

1 answer

0

The sklearn logistic regression is used to classify and implements this method which is able to distinguish between two different classes (eg, sick and healthy), so that it works the fit () method call receives two parameters, the first are its "observations" in the form of a matrix and the second a vector with the classes corresponding to each of the observations, in your case, I believe the problem is that you are passing a DataFrame as the second parameter, you may want to try this LogisticRegression().fit(x, y.C) .

Note that this method is similar to the Excel Proj.log (log) that approaches a curve of the form y = b * (m1 ^ x1) * (m2 ^ x2) ... (mn ^ xn). logistic regression approaches a curve this way .

    
22.09.2016 / 19:09