Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. def plot_roc(probas, y_true):
  2. plt.figure(figsize=(15,5))
  3. mean_tpr = 0.0
  4. mean_fpr = np.linspace(0, 1, 100)
  5. all_tpr = []
  6.  
  7. classes = np.unique(y_true)
  8. perclass_mean_tpr = 0.0
  9. roc_auc = 0
  10. for j in classes:
  11. fpr, tpr, thresholds = mt.roc_curve(y_true, probas[:, j], pos_label=j)
  12. perclass_mean_tpr += interp(mean_fpr, fpr, tpr)
  13. perclass_mean_tpr[0] = 0.0
  14. roc_auc += mt.auc(fpr, tpr)
  15. plt.plot(fpr,tpr,'--',lw=.5,label='Class ROC for ensemble, AUC=%0.4f'
  16. %(mt.auc(fpr, tpr)) )
  17.  
  18. perclass_mean_tpr /= len(classes)
  19. roc_auc /= len(classes)
  20. mean_tpr += perclass_mean_tpr
  21.  
  22. plt.plot(mean_fpr,perclass_mean_tpr,'-',lw=2,label='Mean Class ROC for ensemble, AUC=%0.4f'
  23. %(roc_auc))
  24. plt.legend(loc='best')
  25. plt.xlabel('false positive rate')
  26. plt.ylabel('true positive rate')
  27. plt.title('ROC Curve')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement