Python 使用scikit learn绘制接收器工作特性时出现问题?

Python 使用scikit learn绘制接收器工作特性时出现问题?,python,python-2.7,matplotlib,machine-learning,scikit-learn,Python,Python 2.7,Matplotlib,Machine Learning,Scikit Learn,我想绘制接收器工作特性曲线,因此我执行以下操作: from sklearn.metrics import roc_curve, auc predictions = auto_wclf.predict_proba(X_test) false_positive_rate, recall, thresholds = roc_curve(y_test, predictions[:, 1]) roc_auc = auc(false_positive_rate, recall) plt.title('Rec

我想绘制接收器工作特性曲线,因此我执行以下操作:

from sklearn.metrics import roc_curve, auc
predictions = auto_wclf.predict_proba(X_test)
false_positive_rate, recall, thresholds = roc_curve(y_test, predictions[:, 1])
roc_auc = auc(false_positive_rate, recall)
plt.title('Receiver Operating Characteristic')
plt.plot(false_positive_rate, recall, 'b', label='AUC = %0.2f' % roc_auc)
plt.legend(loc='lower right')
plt.plot([0, 1], [0, 1], 'r--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.0])
plt.ylabel('Recall')
plt.xlabel('Fall-out')
plt.show()
但我有一个例外:

Traceback (most recent call last):
  File "plot.py", line 172, in <module>
    false_positive_rate, recall, thresholds = roc_curve(y_test, predictions[:, 1])
  File "plot.py", line 890, in roc_curve
    y_true, y_score, pos_label=pos_label, sample_weight=sample_weight)
  File "/usr/local/lib/python2.7/site-packages/sklearn/metrics/metrics.py", line 710, in _binary_clf_curve
    raise ValueError("Data is not binary and pos_label is not specified")
ValueError: Data is not binary and pos_label is not specified
回溯(最近一次呼叫最后一次):
文件“plot.py”,第172行,在
假阳性率,回忆,阈值=roc曲线(y检验,预测[:,1])
roc_曲线中第890行的文件“plot.py”
y_为真,y_分数,位置标签=位置标签,样本重量=样本重量)
文件“/usr/local/lib/python2.7/site packages/sklearn/metrics/metrics.py”,第710行,在二进制clf曲线中
raise VALUE ERROR(“数据不是二进制的,未指定pos_标签”)
ValueError:数据不是二进制的,并且未指定pos_标签
我有一个多标签分类问题(5类)。知道怎么画吗?。提前感谢各位。

是的,ROC曲线”是一个图形图,说明了二元分类器系统的性能,因为其辨别阈值是变化的“()

此外,“对于两个以上类别的分类问题,ROC曲线的扩展一直很麻烦,因为自由度随类别数量的增加而二次增加,ROC空间有c(c-1)维,其中c是类别数量。”()因为有5个类别,甚至多标签,ROC曲线不适合你


使用诸如、、之类的指标-选择最适合您任务的指标。

ROC曲线是否仅用于二进制分类?。