In [1]:
from sklearn.metrics import roc_curve
import matplotlib.pyplot as plt
In [2]:
y_true = [0, 0, 0, 0, 1, 1, 1, 1]
y_score = [0.2, 0.3, 0.6, 0.8, 0.4, 0.5, 0.7, 0.9]
In [3]:
roc = roc_curve(y_true, y_score)
In [4]:
print(type(roc))
In [5]:
print(len(roc))
In [6]:
fpr, tpr, thresholds = roc_curve(y_true, y_score)
In [7]:
print(fpr)
In [8]:
print(tpr)
In [9]:
print(thresholds)
In [10]:
plt.plot(fpr, tpr, marker='o')
plt.xlabel('FPR: False positive rate')
plt.ylabel('TPR: True positive rate')
plt.grid()
plt.savefig('data/dst/sklearn_roc_curve.png')
plt.close()
In [11]:
fpr_all, tpr_all, thresholds_all = roc_curve(y_true, y_score,
drop_intermediate=False)
In [12]:
print(fpr_all)
In [13]:
print(tpr_all)
In [14]:
print(thresholds_all)
In [15]:
plt.plot(fpr_all, tpr_all, marker='o')
plt.xlabel('FPR: False positive rate')
plt.ylabel('TPR: True positive rate')
plt.grid()
plt.savefig('data/dst/sklearn_roc_curve_all.png')
plt.close()