How to encode y to classnames?

For example, learn.get_preds() returns a tensor containing y_true like so: [0 0 1 1 0 1].
How do I know whether 0 represents class blue or red if I had two classify on colors, i.e?

I think I found one solution here:

learn.dls.vocab returns a list of the class labels. My best guess is that the index refers to the class label, i.e. for ['cat', 'dog'] it would be 0 = cat, 1 = dog

1 Like

Correct. The only case where this isn’t true is doing text, as vocab is the text vocab. There (though this is valid in any application too), you should do dls.categorize.vocab

1 Like