UndefinedMetricWarning: No positive samples in y_true, true positive value should be meaningless UndefinedMetricWarning)

Question:

I got this warning

UndefinedMetricWarning: No positive samples in y_true, true positive
value should be meaningless UndefinedMetricWarning)

Do you have any idea what it means?

Asked By: pierre

||

Answers:

This means that all the values in y_true are zeros, which means there is no positive class records in the given dataset.

Try the following to understand the distribution of classes in your dataset.

from collections import Counter
Counter(y_true) # y_true must be your labels
Answered By: Venkatachalam

For me, I got this error when I erroneously passed a pos_label param.

The docs say the y_true param should be "binary labels. If labels are not either {-1, 1} or {0, 1}, then pos_label should be explicitly given."

However my scores happened to be all 0 and 1 omitting the pos_label parameter solved it for me!

Answered By: s2t2
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.