Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def plot_two_roc_curves(roc_curves_list1, roc_curves_list2):
- fig = plt.figure(figsize=(10, 10), dpi=1200)
- mean_tpr1 = 0.0
- mean_fpr1 = np.linspace(0, 1, 100)
- mean_tpr2 = 0.0
- mean_fpr2 = np.linspace(0, 1, 100)
- for i in range(len(roc_curves_list1)):
- fpr1, tpr1 = roc_curves_list1[i][0], roc_curves_list1[i][1]
- mean_tpr1 += interp(mean_fpr1, fpr1, tpr1)
- mean_tpr1[0] = 0.0
- #plt.plot(fpr, tpr, lw=1, label='ROC fold %d (area = %0.2f)' % (i, roc_auc_list[i]))
- for i in range(len(roc_curves_list2)):
- fpr2, tpr2 = roc_curves_list2[i][0], roc_curves_list2[i][1]
- mean_tpr2 += interp(mean_fpr2, fpr2, tpr2)
- mean_tpr2[0] = 0.0
- plt.plot([0, 1], [0, 1], '--', color=(0.6, 0.6, 0.6), label='Luck')
- mean_tpr1 /= len(roc_curves_list1)
- mean_tpr1[-1] = 1.0
- mean_auc1 = metrics.auc(mean_fpr1, mean_tpr1)
- mean_tpr2 /= len(roc_curves_list2)
- mean_tpr2[-1] = 1.0
- mean_auc2 = metrics.auc(mean_fpr2, mean_tpr2)
- #print(mean_auc)
- plt.plot(mean_fpr1, mean_tpr1, 'k--',
- label='Mean ROC 1(area = %0.2f)' % mean_auc1, lw=2)
- plt.plot(mean_fpr2, mean_tpr2, 'k:',
- label='Mean ROC 2(area = %0.2f)' % mean_auc1, lw=2)
- plt.xlim([-0.05, 1.05])
- plt.ylim([-0.05, 1.05])
- plt.xlabel('False Positive Rate')
- plt.ylabel('True Positive Rate')
- plt.title('Receiver operating characteristic example')
- plt.legend(loc="lower right")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement