ROC and PR curves logging

Hi!
I am using (and loving) Wandb so far :slight_smile:

Today I wanted to log my validation roc and pr curves, and I used the command:

wandb.log({"val_roc" : wandb.plot.roc_curve(target_list.numpy(), pred_list.numpy(), labels=None, classes_to_plot=None)})

My task is a binary classification, and my data is in numpy array in the format [m,n], with m the number of samples and n the number of classes, my case 1 (i.e. [128,1]).

I am encountering the following error:

  File "/home/mgiordano/.pyenv/versions/3.8.11/envs/sepsis/lib/python3.8/site-packages/wandb/plot/roc_curve.py", line 74, in roc_curve
    y_true, y_probas[..., i], pos_label=classes[i]
IndexError: index 1 is out of bounds for axis 1 with size 1

I think Wandb is trying to compute the curves on other classes, that are not there. Am I missing something?

Thanks!

Hi @mgiordy, happy to help. Could you verify the shape of your arrays that you are passing to the plotting function. We’ll review the roc chart function for any errors and get back to you.

Hey, thanks for replying! The dimension is (430,1) :slight_smile:

Hey @mgiordy !

The ROC curve expects a [n, 2] array - A value for positive classification and a value for negative classification.

You most likely want to create a second axis with value 1 - axis_1.

Hey thanks for getting back :slight_smile:
Can it be that it expects a [n,2] array for the prediction and a [n] array with the ground truth? In that case no error is reported, otherwise if I pass the same format to both I get the following error: ValueError: multilabel-indicator format is not supported.

Thanks!

I think for your case the y_true array must be flattened => (430,)