我試圖從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曲線的代碼。 –