Getting the warning UndefinedMetricWarning: Precision and F-score are ill-defined and being set to 0.0 in labels with no predicted samples
when I calculate the confusion matrix of my classification model through the scikit-learn
's confusion_matrix
function. I have re-confirmed that the class 1
contains images for training, validation, and test purposes just like the other classes. How can I fix this issue?
Here is the output:
[[115 0 17 66 96 183 18]
[ 11 0 2 10 8 21 2]
[ 42 0 35 68 102 172 93]
[ 15 0 9 690 63 102 19]
[ 12 0 7 86 315 186 13]
[ 27 0 13 84 151 317 15]
[ 8 0 18 44 46 30 254]]
And here is my classification report:
precision recall f1-score support
0 0.500 0.232 0.317 495
1 0.000 0.000 0.000 54
2 0.347 0.068 0.114 512
3 0.658 0.768 0.709 898
4 0.403 0.509 0.450 619
5 0.314 0.522 0.392 607
6 0.614 0.635 0.624 400
accuracy 0.481 3585
macro avg 0.405 0.391 0.372 3585
weighted avg 0.475 0.481 0.451 3585