我运行一个python程序,它调用sklearn.metrics
的方法来计算精度和F1分数。以下是没有预测样本时的输出:
/xxx/py2-scikit-learn/0.15.2-comp6/lib/python2.6/site-packages/sklearn/metr\
ics/metrics.py:1771: UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples.
'precision', 'predicted', average, warn_for)
/xxx/py2-scikit-learn/0.15.2-comp6/lib/python2.6/site-packages/sklearn/metr\
ics/metrics.py:1771: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.
'precision', 'predicted', average, warn_for)
当没有预测样本时,表示TP+FP为0,所以
在我的例子中,sklearn.metrics
还返回0.8的准确性,并返回0。所以FN不是零。
但为什么希基勒恩说F1定义不清?
Scikilern对F1的定义是什么?
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/metrics/classification.py
precision=TP/(TP+FP),正如你刚才说的,如果predictor根本不预测正类,那么precision是0。
回忆=TP/(TP+FN),如果预测因子不能预测阳性类别-TP为0-回忆为0。
现在你把0/0除以。
精确性、召回率、F1分数和精确性计算
维基百科reference
相关问题 更多 >
编程相关推荐