Scikit-Learn’s fan

Published

October 9, 2022

So far, Melody is a big fan of Scikit-Learn.

She hasn’t used it for too long, but every time she learns something new, there’s always an elegant way to do it using Scikit-Learn.

But today is perhaps the exception: Melody finished training a multi-class classification model, and after displaying Scikit-Learn’s classification report, she noticed something wasn’t right.

She has to analyze the Macro-average, Micro-average, and Weighted F1-Score values for her model, but the classification report doesn’t display the Micro-average F1-Score.

How can Melody move forward?

  1. The Micro-average F1-Score is the same as the model’s accuracy. Melody can run her analysis using the accuracy of her model.

  2. The Micro-average F1-Score is the same as the model’s precision. Melody can run her analysis using the precision of her model.

  3. The Micro-average F1-Score is the same as the model’s recall. Melody can run her analysis using the recall of her model.

  4. Melody will need to compute the Micro-average F1-Score of her model manually.

1

When we work on multi-class classification problems, it’s simple to compute the F1-Score for each class. Several strategies exist to calculate a global F1-Score representing the entire model’s performance: Macro-average F1-Score, Micro-average F1-Score, and Weighted F1-Score.

Scikit-Learn’s classification report shows all three of these metrics but uses a different name for the Micro-average F1-Score. That’s why Melody is confused.

The Micro-average F1-Score is a metric where we sum all of the contributions from each category to compute an aggregated F1-Score. Micro-average F1-Score calculates the proportion of correctly classified samples out of all samples, which is the model’s accuracy definition.

In any multi-class classification problem, the Micro-average F1-Score is the same as the accuracy. That’s why Scikit-Learn displays it under the “accuracy” label.

Recommended reading