Data Science Asked on March 28, 2021
Here is the part of the code for ROC AUC Curve calculation for multiple classes.
n_classes= 5
y_test = [0,1,1,2,3,4] #actual value
pred1 = [0,1,1,1,3,4] #predicted value
fpr = dict()
tpr = dict()
roc_auc = dict()
for i in range(n_classes):
fpr[i], tpr[i], _ = roc_curve(np.array(pd.get_dummies(y_test))[:, i], np.array(pd.get_dummies(pred1))[:, i])
roc_auc[i] = auc(fpr[i], tpr[i])
Error :
I understand that there are only 4 classes are predicted 0,1,3,4
in pred1 and 5 classes 0,1,2,3,4
in the y_test. So this error arises.
How to solve this error.
df = pd.get_dummies(pred1)
df.insert(loc=2,column='2',value=0)
#print(df)
add this before the for loop and instead of using pd.get_dummies(y_test) use only df
Correct answer by Madhur Yadav on March 28, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP