Plot ROC curve from multiclass classifier with varying probability using scikit

自闭症网瘾萝莉.ら 提交于 2019-12-11 15:28:16

问题


The output of my multi-class classifier looks like this as shown below for which i need to plot ROC curve and get auc

Utterence   Actual   Predicted   Conf_intent1 Conf_Intent2 Conf_Intent3  

Uttr 1      Intent1  Intent1      0.86           0.45         0.24
Uttr2       Intent3  Intent2      0.47           0.76         0.55
Uttr3       Intent1  Intent1      0.70           0.20         0.44
Uttr4       Intent3  Intent2      0.42           0.67         0.56
Uttr5       Intent1  Intent1      0.70           0.55         0.36
Note: Probability is done on absolute scoring so will not add to 1 for particular utterence the highest probability will be predicted

From my code I have made the confusion matrix like this:

import pandas as pd 
import numpy as np 
from sklearn.metrics import multilabel_confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn.metrics import classification_report

#reading the input file
df = pd.read_excel('C:\\testsamples.xlsx')

#Converting the columns to array
actual = df['Actual'].to_numpy()
predicted = df['Predicted'].to_numpy()


mcm = multilabel_confusion_matrix(actual, predicted)

How can I plot ROC curve from this for each Intent1,2 and 3 and take out relevant information such as auc?

来源:https://stackoverflow.com/questions/58006566/plot-roc-curve-from-multiclass-classifier-with-varying-probability-using-scikit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!