Loss weighting imbalanced data

I have a binary classification problem with highly imbalanced data (250 negatives for every 1 positive). If I use NLLLoss (or CrossEntropyLoss), what should the class weights be?

I’m also testing the custom BCE Loss function at [SOLVED] Class Weight for BCELoss.

Thanks so much!

1 Like

they should be [1 / 250, 1] i think.

1 Like

Thanks. My classification problem is mutually exclusive; how would I create a confusion matrix with predictions of [N x 2]?

Which column of predictions should I evaluate?

1 Like

This is assuming that your first label is ‘negative’ and second label is ‘positive’. I am wondering if a better choice would be to use [1, 250] if the gradient values are very small.