Programmers learn & share
+1 vote
75 views

Problem :

I am facing bellow strange error
undefinedmetricwarning: precision is ill-defined and being set to 0.0 due to no predicted samples.
by (6.9k points)   | 75 views

1 Answer

0 votes

Solution :

I had faced similar issue in the past.

 Please use the bellow lines of code

from sklearn.metrics import f1_score
metrics.f1_score(y_test, y_pred, labels=np.unique(y_pred))

This will remove your warning and will give you the result you wanted

by (36.1k points)  
2,182 questions
2,459 answers
59 comments
241 users