2
votes

I am running this code:

from sklearn import cross_validation
import numpy as np
import sys
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import datasets, svm, metrics

digits = datasets.load_digits()

X_train, X_test, y_train, y_test = cross_validation.train_test_split(
digits.data, digits.target, test_size=0.4, random_state=0)

clf = linear_model.LogisticRegression(X_train, y_train) 
clf.fit(X_train, y_train)

I am getting this error:

AttributeError: 'numpy.ndarray' object has no attribute 'lower'

How can make the logistic model fit?

2
Welcome to SO! Could you give some more details about the error? Where does the error occur? Which line? What does the stacktrace look like? - musically_ut

2 Answers

3
votes

You shouldn't pass X_train and y_train to LogisticRegression constructor. You need just

...

clf = linear_model.LogisticRegression() 
clf.fit(X_train, y_train)
0
votes

clf = LogisticRegression() clf.fit(x_train,x_test)

don't pass parameters inside LogisticRegression Model