Predifinition
Suppose that there is a set \(s\) to be predicted as class \(c\). A data point in \(s\) is can be predicted as positive (P, means belonging to \(c\)), or negative (N, means belonging to other classes)
Predicted P | Predicgted N | |
---|---|---|
P | TP | FN |
N | FP | TN |
TP: Actual Positive, Predicted as Positive FN: Actual Positive, Predicted as Negative TN: Actual Negative, Predicted as Negative FP: Actual Negative, Predicted as Positive
Standard Criteria
Precision
\(P(c)=\frac{TP_c}{TP_c + FP_c}\)
Recall
\(R(c)=\frac{TP_c}{TP_c + FN_c}\)
F1
\(F1(c)=2× \frac{P(c)×R(c)}{P(c)+R(c)}\)
Macro Criteria
Note that the Macro Criteria will highly influenced by the small classes. |C| is the number of classes.
Macro Precision
\(P_{macro}=\sum_{c}\frac{P(c)}{|C|}\)
Macro Recall
\(R_{macro}=\sum_c\frac{R(c)}{|C|}\)
Macro F1
\(F1_{macro}=\sum_c\frac{F1(c)}{|C|}\)
Micro Criteria
\(P_{micro}=R_{micro}=F1_{micro}=\sum_c\frac{TP(c)}{|D|}\) , where |D| is the size of data set.
Weighted Criteria
Weighted Precision
\(P_{weighted}=\sum_c\frac{|c|}{|D|}P(c)\)
Weighted Recall
\(R_{weighted}=\sum_c\frac{|c|}{|D|}R(c)\)
Weighted F1 \(F1_{weighted}=\sum_c\frac{|c|}{|D|}F1(c)\)