Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Y_pred = y_pred.tolist()
- Y_pred = np.array(Y_pred)
- Y_test = np.array(y_test)
- from sklearn.datasets import make_classification
- from sklearn.model_selection import train_test_split
- # multi-class classification
- from sklearn.multiclass import OneVsRestClassifier
- from sklearn.linear_model import LogisticRegression
- from sklearn.model_selection import train_test_split
- from sklearn.metrics import roc_curve
- from sklearn.metrics import roc_auc_score
- fpr = {}
- tpr = {}
- thresh ={}
- for i in range(n_class):
- fpr[i], tpr[i], thresh[i] = roc_curve(Y_test, Y_pred[:,i], pos_label=i)
- colors = ['orange', 'green', 'blue', 'purple', 'cyan']
- # plotting
- for i in range(n_class):
- plt.plot(fpr[i], tpr[i], linestyle='--',color=colors[i], label=f'Class {i} vs Rest')
- plt.title('Multiclass ROC curve')
- plt.xlabel('False Positive Rate')
- plt.ylabel('True Positive rate')
- plt.legend(loc='best')
- plt.savefig('Multiclass ROC',dpi=300);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement