【发布时间】:2021-03-15 01:04:48
【问题描述】:
我正在尝试获得 10 节课的 ROC。我使用了 CNN 模型(keras)。我能够得到一对休息曲线,但我想得到一对一。 以下是我的代码的sn-p。
model.compile(optimizer=keras.optimizers.Adam(0.001),
loss='categorical_crossentropy',
metrics=['acc'])
from keras.callbacks import History
history = History()
model.fit_generator(generator=train_generator, callbacks= [history],
validation_data=valid_generator,epochs=10)
score = model.evaluate_generator(test_generator)
x, y = test_generator.next()
prediction = model.predict(x)
predict_label1 = np.argmax(prediction, axis=-1)
true_label1 = np.argmax(y, axis=-1)
y = np.array(true_label1)
scores = np.array(predict_label1)
fpr, tpr, thresholds = metrics.roc_curve(y, scores, pos_label=9)
roc_auc = metrics.auc(fpr, tpr)
plt.figure()
lw = 2
plt.plot(fpr, tpr, color='darkorange',
lw=lw, label='ROC curve (area = %0.2f)' % roc_auc)
plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic (ROC)')
plt.legend(loc="lower right")
plt.show()
此代码生成一个 vs 静止曲线但是我想得到这样的曲线picture 可以这样做吗? 我们将不胜感激。
【问题讨论】:
-
您提到的“一对一”ROC 曲线是否适用于一个绘图中的多个一对一 ROC 曲线?
-
据我所知,ROC曲线是为了找到两个类的阈值,而one vs all方法将所有其他类视为一个类。
-
@krenrd 我想要上面附图中的图片。
标签: python keras conv-neural-network roc auc