Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LogisticRegression: ValueError: setting an array element with a sequence #28

Closed
fhlkm opened this issue Oct 28, 2014 · 1 comment
Closed

Comments

@fhlkm
Copy link

fhlkm commented Oct 28, 2014

I am using logisticRegression model for my project , my code is as folows,i don't know why every time after do it there is an error: "ValueError: setting an array element with a sequence."

I don't know why?

from sklearn.linear_model import LogisticRegression

trainX= [['39', 'State-gov', '77516', 'Bachelors', '13', 'Never-married', 'Adm-clerical', 'Not-in-family', 'White', 'Male', '2174', '0', '40', 'United-States'], ['50', 'Self-emp-not-inc', '83311', 'Bachelors', '13', 'Married-civ-spouse', 'Exec-managerial', 'Husband', 'White', 'Male', '0', '0', '13', 'United-States']]

model = LogisticRegression()

trainY=['<=50K', '<=50K']

model.fit(dataX,dataY)

@aronwc
Copy link
Member

aronwc commented Oct 28, 2014

trainX and trainY should be floats or ints, not strings.

DictVectorizer may help:
http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.DictVectorizer.html

-Aron

On Mon, Oct 27, 2014 at 10:00 PM, timfeng notifications@github.com wrote:

I am using logisticRegression model for my project , my code is as
folows,i don't know why every time after do it there is an error:
"ValueError: setting an array element with a sequence."

I don't know why?

from sklearn.linear_model import LogisticRegression

trainX= [['39', 'State-gov', '77516', 'Bachelors', '13', 'Never-married',
'Adm-clerical', 'Not-in-family', 'White', 'Male', '2174', '0', '40',
'United-States'], ['50', 'Self-emp-not-inc', '83311', 'Bachelors', '13',
'Married-civ-spouse', 'Exec-managerial', 'Husband', 'White', 'Male', '0',
'0', '13', 'United-States']]

model = LogisticRegression()

trainY=['<=50K', '<=50K']

model.fit(dataX,dataY)


Reply to this email directly or view it on GitHub
#28.

@aronwc aronwc closed this as completed Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants