为什么sklearn Logistic回归会引发此错误?

时间:2019-06-15 04:22:45

标签: python scikit-learn

我正在使用sklearn进行Logistic回归,并且具有以下内容:

print(X)
[[4.6142807 0.        0.        ... 0.        0.        0.       ]
 [7.9282722 0.        0.        ... 0.        0.        0.       ]
 [4.6142807 0.        0.        ... 0.        0.        0.       ]
 ...
 [0.        0.        0.        ... 0.        0.        0.       ]
 [0.        0.        0.        ... 0.        0.        0.       ]
 [4.6142807 0.        0.        ... 0.        0.        0.       ]]

print(Y)

[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]

logr = LogisticRegressionCV(max_iter=1000, cv=5)

logr.fit(X, Y)
print('cross_val_score', cross_val_score(logr, X, Y, cv=5, scoring='accuracy'))

但是我得到了错误

ValueError: This solver needs samples of at least 2 classes in the data, but the data contains only one class: 0

0 个答案:

没有答案
相关问题