A classifier on 1,000 test examples has TP = 10, FN = 10, FP = 5 and TN = 975. Compute the accuracy, the F1 score and the Matthews correlation coefficient, . What do these give for a model that always predicts negative?
ML systems and evaluation, Classification metrics
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can compute MCC from a confusion matrix and explain why it is more informative than accuracy on imbalanced data.
Key idea
, where are true positives, false negatives, false positives and true negatives. It is the correlation between predicted and true labels, from to , and uses all four cells.
Steps
- Compute accuracy: . This looks high, yet only of the examples are positive.
- Compute precision, recall and : precision , recall , so .
- Compute MCC: the numerator is , and the denominator is , giving .
- Evaluate the always-negative model (, , ): accuracy is (only percentage points below our model), while recall and drop to .
- Evaluate MCC for the always-negative model: the factor makes the denominator zero, so by convention is set to (no better than chance), matching intuition since the model learnt nothing.
- Compare the metrics: accuracy barely separates a useful model from a trivial one ( vs ), whereas separates them clearly ( vs ) and, unlike , also rewards correct negatives so it treats both classes symmetrically.
Common mistakes
- Forgetting the square root in the denominator, or using only.
- Reporting MCC as undefined for the all-negative model. Libraries return by convention, and the answer should say what it means.
- Treating MCC and as interchangeable because they are close here (0.570 and 0.571). That is a coincidence; ignores true negatives and MCC does not.
How long your answer should be
Half a page; 4 minutes.
Read this
Previous in ML systems and evaluation: Two classifiers A and B are evaluated on the same 200 test examples. Both are right on 150, both are wrong on 15, only A is right on 25 and only B is right on 10. Test at the 5% level, using McNemar's statistic (where and count the examples on which only one of the two classifiers is right) and the 5% critical value , whether the difference in accuracy is real. Why not simply compare the two accuracies?
Next in ML systems and evaluation: How do you evaluate the retriever in a RAG (retrieval-augmented generation) system separately from the generator? Suppose three queries have relevant chunk IDs , and , and the retriever returns top-5 lists , and . What are the recall@5, precision@5, hit rate@5 and MRR (mean reciprocal rank), and how does scoring both retrieval and generation let you separate a retrieval miss from a generation error?