28
$\begingroup$

I have below an example I pulled from sklearn 's sklearn.metrics.classification_report documentation.

What I don't understand is why there are f1-score, precision and recall values for each class where I believe class is the predictor label? I thought the f1 score tells you the overall accuracy of the model. Also, what does the support column tell us? I couldn't find any info on that.

print(classification_report(y_true, y_pred, target_names=target_names))
             precision    recall  f1-score   support

    class 0       0.50      1.00      0.67         1
    class 1       0.00      0.00      0.00         1
    class 2       1.00      0.67      0.80         3

avg / total       0.70      0.60      0.61         5
$\endgroup$
21
$\begingroup$

The f1-score gives you the harmonic mean of precision and recall. The scores corresponding to every class will tell you the accuracy of the classifier in classifying the data points in that particular class compared to all other classes.

The support is the number of samples of the true response that lie in that class.

You can find documentation on both measures in the sklearn documentation.

Support - http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html

F1-score - http://scikit-learn.org/stable/modules/generated/sklearn.metrics.f1_score.html

EDIT

The last line gives a weighted average of precision, recall and f1-score where the weights are the support values. so for precision the avg is (0.50*1 + 0.0*1 + 1.0*3)/5 = 0.70. The total is just for total support which is 5 here.

$\endgroup$
  • 1
    $\begingroup$ what about the last line avg / total? It does not seem to match the column means... How is it computed and what does it mean? $\endgroup$ – Antoine Oct 19 '16 at 8:03
  • $\begingroup$ @Antoine I am also wondering the same. Did you find out how is it calculated? $\endgroup$ – Pale Blue Dot May 16 '17 at 15:32
  • $\begingroup$ @Antoine The last line gives a weighted average of precision, recall and f1-score where the weights are the support values. so for precision the avg is (0.50*1 + 0.0*1 + 1.0*3)/5 = 0.70. The total is just for total support which is 5 here. $\endgroup$ – Nitin May 21 '17 at 3:56
  • $\begingroup$ Thanks to previous answer of @Nitin I found by links the best visual descriptions and intuition behind math: en.wikipedia.org/wiki/Precision_and_recall en.wikipedia.org/wiki/F1_score $\endgroup$ – Bogdan Korecki Oct 2 '18 at 16:16

protected by Reinstate Monica Mar 5 at 18:32

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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