Hello, I want to do roc auc plot for every class in a problem where the labels are: 0, 1, 2, 3, 4 ,5 ,6.
I found this code:
label_binarize(YTest, classes=[0, 1, 2, 3, 4, 5, 6])
n_classes = YTest.shape[1]
classifier = OneVsRestClassifier(
svm.SVC(kernel="linear", probability=True, random_state=random_state)
)
y_score = classifier.fit(XTest, YTest).decision_function(XTest)
fpr = dict()
tpr = dict()
roc_auc = dict()
for i in range(n_classes):
fpr[i], tpr[i], _ = roc_curve(YTest[:, i], y_score[:, i])
roc_auc[i] = auc(fpr[i], tpr[i])
fpr["micro"], tpr["micro"], _ = roc_curve(YTest.ravel(), y_score.ravel())
roc_auc["micro"] = auc(fpr["micro"], tpr["micro"])
I have some problem with svm and decision_function. Is there a better way to solve this problem?