UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples

后端 未结 6 2078
野的像风
野的像风 2020-11-28 04:20

I\'m getting this weird error:

classification.py:1113: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted sample         


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 04:34

    According to @Shovalt's answer, but in short:

    Alternatively you could use the following lines of code

        from sklearn.metrics import f1_score
        metrics.f1_score(y_test, y_pred, labels=np.unique(y_pred))
    

    This should remove your warning and give you the result you wanted, because it no longer considers the difference between the sets, by using the unique mode.

提交回复
热议问题