Machine learning scikit学习计算多标签分类中的F1
我正在尝试使用scikit计算宏F1 但是,它失败了,并显示错误消息Machine learning scikit学习计算多标签分类中的F1,machine-learning,nlp,scikit-learn,precision-recall,Machine Learning,Nlp,Scikit Learn,Precision Recall,我正在尝试使用scikit计算宏F1 但是,它失败了,并显示错误消息 ValueError: multiclass-multioutput is not supported 如何使用多标签分类计算宏F1?在当前scikit学习版中,您的代码会导致以下警告: DeprecationWarning: Direct support for sequence of sequences multilabel representation will be unavailable from vers
ValueError: multiclass-multioutput is not supported
如何使用多标签分类计算宏F1?在当前scikit学习版中,您的代码会导致以下警告:
DeprecationWarning: Direct support for sequence of sequences multilabel
representation will be unavailable from version 0.17. Use
sklearn.preprocessing.MultiLabelBinarizer to convert to a label
indicator representation.
按照此建议,您可以使用将此多标签类转换为f1\u score
接受的表单。例如:
from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.metrics import f1_score
y_true = [[1,2,3]]
y_pred = [[1,2,3]]
m = MultiLabelBinarizer().fit(y_true)
f1_score(m.transform(y_true),
m.transform(y_pred),
average='macro')
# 1.0
想知道如何为多元回归问题实现这一点。
from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.metrics import f1_score
y_true = [[1,2,3]]
y_pred = [[1,2,3]]
m = MultiLabelBinarizer().fit(y_true)
f1_score(m.transform(y_true),
m.transform(y_pred),
average='macro')
# 1.0