For a typical single class classification problem, you would typically perform the following:
from sklearn.metrics import roc_auc_scoreroc_auc_score(y_test,y_pred)
However, when you try to use roc_auc_score on a multi-class variable, you will receive the following error:
Therefore, I created a function using LabelBinarizer() in order to evaluate the AUC ROC score for my multi-class problem:
def multiclass_roc_auc_score(y_test, y_pred, average="macro"):lb = LabelBinarizer()
lb.fit(y_test)y_test = lb.transform(y_test)
y_pred = lb.transform(y_pred)return roc_auc_score(y_test, y_pred, average=average)