Advertisement
Guest User

Untitled

a guest
May 25th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. def plot_two_roc_curves(roc_curves_list1, roc_curves_list2):
  2. fig = plt.figure(figsize=(10, 10), dpi=1200)
  3.  
  4. mean_tpr1 = 0.0
  5. mean_fpr1 = np.linspace(0, 1, 100)
  6.  
  7. mean_tpr2 = 0.0
  8. mean_fpr2 = np.linspace(0, 1, 100)
  9.  
  10.  
  11. for i in range(len(roc_curves_list1)):
  12. fpr1, tpr1 = roc_curves_list1[i][0], roc_curves_list1[i][1]
  13. mean_tpr1 += interp(mean_fpr1, fpr1, tpr1)
  14. mean_tpr1[0] = 0.0
  15.  
  16. #plt.plot(fpr, tpr, lw=1, label='ROC fold %d (area = %0.2f)' % (i, roc_auc_list[i]))
  17.  
  18. for i in range(len(roc_curves_list2)):
  19. fpr2, tpr2 = roc_curves_list2[i][0], roc_curves_list2[i][1]
  20. mean_tpr2 += interp(mean_fpr2, fpr2, tpr2)
  21. mean_tpr2[0] = 0.0
  22.  
  23. plt.plot([0, 1], [0, 1], '--', color=(0.6, 0.6, 0.6), label='Luck')
  24.  
  25. mean_tpr1 /= len(roc_curves_list1)
  26. mean_tpr1[-1] = 1.0
  27. mean_auc1 = metrics.auc(mean_fpr1, mean_tpr1)
  28.  
  29. mean_tpr2 /= len(roc_curves_list2)
  30. mean_tpr2[-1] = 1.0
  31. mean_auc2 = metrics.auc(mean_fpr2, mean_tpr2)
  32.  
  33. #print(mean_auc)
  34. plt.plot(mean_fpr1, mean_tpr1, 'k--',
  35. label='Mean ROC 1(area = %0.2f)' % mean_auc1, lw=2)
  36.  
  37. plt.plot(mean_fpr2, mean_tpr2, 'k:',
  38. label='Mean ROC 2(area = %0.2f)' % mean_auc1, lw=2)
  39.  
  40. plt.xlim([-0.05, 1.05])
  41. plt.ylim([-0.05, 1.05])
  42. plt.xlabel('False Positive Rate')
  43. plt.ylabel('True Positive Rate')
  44. plt.title('Receiver operating characteristic example')
  45. plt.legend(loc="lower right")
  46. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement