pierre
pierre

Reputation: 131

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

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?

Upvotes: 10

Views: 20739

Answers (2)

s2t2
s2t2

Reputation: 2686

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!

Upvotes: 3

Venkatachalam
Venkatachalam

Reputation: 16966

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

Upvotes: 7

Related Questions