我正在运行此代码:
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)
我收到此错误:
AttributeError:'numpy.ndarray'对象没有属性'lower'
如何使逻辑模型适合?
答案 0 :(得分:1)
您不应将X_train
和y_train
传递给LogisticRegression
构造函数。你需要
...
clf = linear_model.LogisticRegression()
clf.fit(X_train, y_train)
答案 1 :(得分:0)
clf = LogisticRegression()
clf.fit(x_train,x_test)
不要在LogisticRegression模型内部传递参数