Scikit学习SGDClassifier仅对一个类进行分类

时间:2019-09-07 09:31:40

标签: python scikit-learn

我正在尝试使用SGDClassifier来解决二进制分类问题,它适用于0类但不适用于1类。

from sklearn.linear_model import SGDClassifier

lri = SGDClassifier(alpha=0.1, loss='log')
lri.fit(tx_train,ty_train)
lri_predictions = lri.predict(tx_test)
print(confusion_matrix(ty_test, lri_predictions), classification_report(ty_test, lri_predictions), sep='\n\n')
[[6022    0]
 [1036    0]]

              precision    recall  f1-score   support

           0       0.85      1.00      0.92      6022
           1       0.00      0.00      0.00      1036

    accuracy                           0.85      7058
   macro avg       0.43      0.50      0.46      7058
weighted avg       0.73      0.85      0.79      7058

0 个答案:

没有答案
相关问题