Search code examples
pythonscikit-learnpytorchmetrics

How to calculate roc auc score for the whole epoch like avg accuracy?


I am implementing a training loop in PyTorch and for metrics, I want to use ROC AUC score using sklearn.metrics.roc_auc_score.

I can use sklearn's implementation for calculating the score for a single prediction but have a little trouble imagining how to use it to calculate the average score for the whole epoch. Can anyone push me in the right direction?


Solution

  • y_true and y_score, in the function can be 1-D arrays, so if you collect the values form the entire epoch, you can directly call the function. Note that if you do multi-label classification, you need to compute the ROC AUC score for each class separately.