In binary classification, we have this:
But how is it in multiclass classification?
We usually do not have any notions of positive or negative.
We only consider multiclass, not multilabel classification.
For accuracy, this is easy:
\(\text{Accuracy} = \frac{\text{Correct predictions}}{\text{All predictions}}\)
As always, accuracy is not the perfect measurement.
It disregards class balance and the cost of different errors.
https://www.evidentlyai.com/classification-metrics/multi-class-metrics
https://www.evidentlyai.com/classification-metrics/multi-class-metrics
To consider precision and recall in multiclass
classification,
obtain these metrics for each class
individually.
For Class A, this becomes:
\(\text{Precision}_{\text{Class A}} = \frac{\text{TP}_{\text{Class A}}}{\text{TP}_{\text{Class A}} + \text{FP}_{\text{Class A}}}\)
\(\text{Recall}_{\text{Class A}} = \frac{\text{TP}_{\text{Class A}}}{\text{TP}_{\text{Class A}} + \text{FN}_{\text{Class A}}}\)
https://www.evidentlyai.com/classification-metrics/multi-class-metrics
https://www.evidentlyai.com/classification-metrics/multi-class-metrics
https://www.evidentlyai.com/classification-metrics/multi-class-metrics
https://www.evidentlyai.com/classification-metrics/multi-class-metrics
In the end, obtain an average of
precision and recall of
individual classes.
Either the macro-average, or the micro-average.
The Macro Average:
\(\text{Precision} = \frac{\text{Precision}_{\text{Class A}} + \dots{} + \text{Precision}_{\text{Class N}}}{N}\)
\(\text{Recall} = \frac{\text{Recall}_{\text{Class A}} + \dots{} + \text{Recall}_{\text{Class N}}}{N}\)
The Micro Average:
\(\text{Precision} = \frac{\text{TP}_{\text{Class A}} + \dots{} + \text{TP}_{\text{Class N}}}{\text{TP}_{\text{Class A}} + \text{FP}_{\text{Class A}} + \dots{} + \text{TP}_{\text{Class N}} + \text{FP}_{\text{Class N}}}\)
\(\text{Recall} = \frac{\text{TP}_{\text{Class A}} + \dots{} + \text{TP}_{\text{Class N}}}{\text{TP}_{\text{Class A}} + \text{FN}_{\text{Class A}} + \dots{} + \text{TP}_{\text{Class N}} + \text{FN}_{\text{Class N}}}\)
Macro-averaging gives equal weight to each class
Micro-averaging gives equal weight to each instance
Macro-average precision is 76%.
Macro-average recall is
71%.
Micro-average precision and recall are both 82%.
https://www.evidentlyai.com/classification-metrics/multi-class-metrics