Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def plot_roc(probas, y_true):
- plt.figure(figsize=(15,5))
- mean_tpr = 0.0
- mean_fpr = np.linspace(0, 1, 100)
- all_tpr = []
- classes = np.unique(y_true)
- perclass_mean_tpr = 0.0
- roc_auc = 0
- for j in classes:
- fpr, tpr, thresholds = mt.roc_curve(y_true, probas[:, j], pos_label=j)
- perclass_mean_tpr += interp(mean_fpr, fpr, tpr)
- perclass_mean_tpr[0] = 0.0
- roc_auc += mt.auc(fpr, tpr)
- plt.plot(fpr,tpr,'--',lw=.5,label='Class ROC for ensemble, AUC=%0.4f'
- %(mt.auc(fpr, tpr)) )
- perclass_mean_tpr /= len(classes)
- roc_auc /= len(classes)
- mean_tpr += perclass_mean_tpr
- plt.plot(mean_fpr,perclass_mean_tpr,'-',lw=2,label='Mean Class ROC for ensemble, AUC=%0.4f'
- %(roc_auc))
- plt.legend(loc='best')
- plt.xlabel('false positive rate')
- plt.ylabel('true positive rate')
- plt.title('ROC Curve')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement