[二分类]F1 score
当前着重于二分类F1 score
计算
精确率和召回率的计算参考[二分类]PR曲线。
[0, 1],其中数值为1表示实现了最好的精确率和召回率,数值为0表示性能最差
python
Python库Sklearn实现了
1 | def f1_score(y_true, y_pred, labels=None, pos_label=1, average='binary', sample_weight=None): |
该函数返回二元分类中正样本的F1 score值
y_true:一维数组,表示正样本标签y_pred:一维数组,表示分类器预测类别pos_label:字符串或者数值,表示正样本类标签,默认为1
示例
参考[二分类]PR曲线实现二元数据集的提取,分类器的训练和预测。F1-score计算如下:
1 | from sklearn.metrics import f1_score |