我的逻辑回归函数有问题,我正在使用 Pycharm IDE 和sklearn.linear_modelpackage LogisticRegression。
我的调试器显示AttributeError 'tuple' object has no attribute 'fit' and 'predict'.
代码如下:
def logistic_regression(df, y):
x_train, x_test, y_train, y_test = train_test_split(
df, y, test_size=0.25, random_state=0)
sc = StandardScaler()
x_train = sc.fit_transform(x_train)
x_test = sc.transform(x_test)
clf = LogisticRegression(random_state=0, solver='sag',
penalty='l2', max_iter=1000, multi_class='multinomial'),
clf.fit(x_train, y_train)
y_pred = clf.predict(x_test)
return classification_metrics.print_metrics(y_test, y_pred, 'Logistic regression')
任何人都可以帮助在这里发现错误吗?因为对于其他功能,我尝试过fit并且predict看起来很好。