Micro & Macro Averaged Precision📊

When it comes to Multi Class Classification, the usual metrics - Precision, Recall, F1, etc. can be tweaked a bit to measure performance for each class.:abcd:

Quick recap- Precision is (TP/TP+FP), Recall is (TP/TP+FN), F1 score is the harmonic mean of the 2.:yawning_face:

:bulb:Macro Averaged Precision: We calculate the precision for each class separately in an One vs All way. And then take the the average of all precision values.

So for 3 classes - a,b,c, I’ll calculate Pa,Pb,Pc and Macro average will be (Pa+Pb+Pc)/3.

:bulb:Micro Averaged Precision: Here we calculate the TP and FP for each class, and then calculate the overall Precision.

So for 3 classes, I’ll calculate TPa,TPb,TPc and similarly FPa,FPb,FPc for each class, and add those. Now using the total TP and total FP, one precision can be calculated.

:bulb:Weighted Precision: Similar to Macro, except that we take the number of instances for each class into consideration as well. These acts as weights.

So for 3 classes-a,b,c, if number of instances are A,B,C respectively, then the weighted overall precision will be total weighted precision divided by total number of instances:

(APa+BPb+CPc)/(A+B+C):thinking::bulb:

Similarly, Recall and F1 can also be calculated.👁️‍🗨️

#datascience #machinelearning