Advertisement
newb_ie

Untitled

Jan 6th, 2022
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Y_pred = y_pred.tolist()
  2. Y_pred = np.array(Y_pred)
  3. Y_test = np.array(y_test)
  4. from sklearn.datasets import make_classification
  5. from sklearn.model_selection import train_test_split
  6.  
  7. # multi-class classification
  8. from sklearn.multiclass import OneVsRestClassifier
  9. from sklearn.linear_model import LogisticRegression
  10. from sklearn.model_selection import train_test_split
  11. from sklearn.metrics import roc_curve
  12. from sklearn.metrics import roc_auc_score
  13.  
  14. fpr = {}
  15. tpr = {}
  16. thresh ={}
  17.  
  18.  
  19.  
  20. for i in range(n_class):
  21. fpr[i], tpr[i], thresh[i] = roc_curve(Y_test, Y_pred[:,i], pos_label=i)
  22. colors = ['orange', 'green', 'blue', 'purple', 'cyan']
  23. # plotting
  24. for i in range(n_class):
  25. plt.plot(fpr[i], tpr[i], linestyle='--',color=colors[i], label=f'Class {i} vs Rest')
  26. plt.title('Multiclass ROC curve')
  27. plt.xlabel('False Positive Rate')
  28. plt.ylabel('True Positive rate')
  29. plt.legend(loc='best')
  30. plt.savefig('Multiclass ROC',dpi=300);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement