2
$\begingroup$

I am using the "classification_report" from:

from sklearn.metrics import classification_report

in order to evaluate a classification model.

enter image description here

How can I read this report? What is the value of precision, recall, and f1-score?

Is the precision = 56% or 25% and also for recall and f1-score?

$\endgroup$
0
$\begingroup$

is it the precision= 56% or 25% and also for recall and f1-score ?

No, because precision, recall and f1-score are defined only for binary classification, and this report is about a multi-class classification problem (with 8 classes).

Note: in order to understand this kind of classification report one needs to first understand how things work in a confusion matrix (with sklearn one can use the function confusion_matrix). A confusion matrix shows for every true class X and every predicted class Y the number of instances which have true class X and are predicted as class Y. The values in the classification report are calculated from the confusion matrix, it's a good exercise to do this calculation manually a few times in order to understand how things work in the classification report.

  • Every line in the first part of the classification report focuses on one class X versus any other class. This means that it gives the precision, recall and f1-score values as if there were only two classes: X and "not X".
  • In the second part of the report the precision, report and f1-score values are aggregated across classes. But there are different ways to aggregate them, and every way means something different (see also this question).
    • Macro-average is the simple average across classes. This means that it doesn't care how many instances each class has, it considers all of them equally important.
    • Weighted average weights each class value with its proportion in the data. This means that it gives more importance to large classes than to small classes, so it tends to mask problems with small classes.

This classifier suffers from a common problem: it ignores all the small classes and predicts only the 3 largest classes 3,4 and 7.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.