我试图从tensorflow提供的CIFAR-10示例的修改版本绘制ROC曲线。它现在为2类,而不是10如何用Tensorflow和scikit-learn绘制ROC曲线?
的网络的输出被称为logits并采取以下形式:
[[-2.57313061 2.57966399] [0.04221377 -0.04033273] [-1.42880082 1.43337202] [ -2.7692945 2.78173304] [-2.48195744 2.49331546] [2.0941515 -2.10268974] [-3.51670194 3.53267646] [-2.74760485 2.75617766] ...]
首先,做这些logits实际上代表什么?网络中的最后一层是WX + b形式的“softmax linear”。
该模型能够通过调用
top_k_op = tf.nn.in_top_k(logits, labels, 1)
然后计算精度,一旦图形已经被初始化:
predictions = sess.run([top_k_op])
predictions_int = np.array(predictions).astype(int)
true_count += np.sum(predictions)
...
precision = true_count/total_sample_count
这工作得很好。
但现在我怎么能从这个绘制ROC曲线?
我一直在尝试“sklearn.metrics.roc_curve()”函数(http://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.html#sklearn.metrics.roc_curve),但我不知道用什么作为我的“y_score”参数。
任何帮助,将不胜感激!
请参阅此处[链接](http://stackoverflow.com/questions/35811446/classification-accuracy-after-recall-and-precision/37275638#37275638)以获得计算并绘制ROC曲线的代码。 –