Skip to content
Advertisement

Macro VS Micro VS Weighted VS Samples F1 Score

In sklearn.metrics.f1_score, the f1 score has a parameter called “average”. What does macro, micro, weighted, and samples mean? Please elaborate, because in the documentation, it was not explained properly. Or simply answer the following:

  1. Why is “samples” best parameter for multilabel classification?
  2. Why is micro best for an imbalanced dataset?
  3. what’s the difference between weighted and macro?

Advertisement

Answer

The question is about the meaning of the average parameter in sklearn.metrics.f1_score.

As you can see from the code:

  • average=micro says the function to compute f1 by considering total true positives, false negatives and false positives (no matter of the prediction for each label in the dataset)
  • average=macro says the function to compute f1 for each label, and returns the average without considering the proportion for each label in the dataset.
  • average=weighted says the function to compute f1 for each label, and returns the average considering the proportion for each label in the dataset.
  • average=samples says the function to compute f1 for each instance, and returns the average. Use it for multilabel classification.
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement