How do you read a confusion matrix and derive the key metrics?
easyAnswer
- Rows = actual class, columns = predicted class (or vice versa).
- Cells: TP, FP, TN, FN.
- Accuracy = (TP+TN)/all.
- Precision = TP/(TP+FP).
- Recall = TP/(TP+FN).
- Specificity = TN/(TN+FP).
- F1 = 2·P·R/(P+R).
- Read it to see which class the model confuses with which — a diagonal-heavy matrix means good separation.
Check yourself — multiple choice
- Precision = TP/(TP+FN)
- Recall = TP/(TP+FP)
- F1 = 2·Precision·Recall / (Precision+Recall)
- Accuracy is always the best metric
F1 is the harmonic mean of precision and recall.
#metrics#classification
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- Precision vs recall — when do you optimize each?
- Why is accuracy a bad primary metric for many real-world problems?
- What is F-beta score and when is F1 not enough?
- Macro vs micro vs weighted averaging in multi-class metrics — how do you choose?
- What is Cohen's kappa and why is it useful?
- What is the Matthews Correlation Coefficient (MCC) and when should you use it?