01Chapter 1: Predictions versus true labelsEvery classification metric in this tutorial is built from one thing: a pair of values for each example. One value is what actually happened, and the other is what the model said. Accuracy, precision, recall, and F1 are different ways of summarizing those pairs. If the pairs are wrong, every metric 8 min read
02Chapter 2: The confusion matrix: TP, FP, TN, FNThis chapter assumes you know basic Python, the idea of supervised classification with labeled data, and what a train/test split is. It also assumes you can work with ratios and percentages. Everything else is built from scratch.8 min read
03Chapter 3: Accuracy: the share of correct predictionsThis chapter assumes you can write basic Python, know what supervised classification with labeled data is, and know why a model is scored on a held-out test set. It also assumes you have read the previous chapter on the confusion matrix. Accuracy is the simplest metric built from those four counts. 7 min read
04Chapter 4: When accuracy misleads: imbalanced classesThis chapter assumes you can read basic Python, know what supervised binary classification is, and have seen a train/test split. You should also know the four confusion matrix cells (TP, FP, TN, FN) and the accuracy formula from earlier in this tutorial. Here you will see why accuracy can look excel7 min read
05Chapter 5: Precision: how trustworthy are positive predictionsThis chapter assumes you can read a confusion matrix (TP, FP, TN, FN), write basic Python, and know why a model is scored on held-out test data. Precision answers one question: when the model says "positive", how often is it right?5 min read
06Chapter 6: Recall: how many real positives were foundThis chapter assumes you can read basic Python and know what a supervised classifier is. It also assumes you know what a train/test split is and have seen the confusion matrix from earlier in this tutorial. Recall is computed from two of its four cells, so a quick review helps.6 min read
07Chapter 7: Choosing a metric by the cost of errorsThis chapter assumes you can already read a confusion matrix (TP, FP, TN, FN) and compute accuracy, precision, and recall from it. You should also know why accuracy misleads on imbalanced data. You need basic Python. Here you will learn to turn the question "which metric should I optimize?" into a q6 min read
08Chapter 8: F1 score: combining precision and recallThis chapter assumes you can already build a confusion matrix and compute precision and recall from TP, FP, and FN. It also assumes basic Python and a train/test split. Here you will learn what the F1 score measures, why it uses a harmonic mean, how to compute it by hand and with scikit-learn, and w6 min read
09Chapter 9: Moving the threshold: precision versus recallThis chapter assumes you can compute precision and recall from confusion matrix counts and read short Python. Earlier chapters covered both, so here we ask what happens when you change the rule that turns a model's score into a yes or no.7 min read
10Chapter 10: Computing the metrics with scikit-learnEarlier chapters computed accuracy, precision, recall, and F1 by hand from the four confusion matrix counts. This chapter shows how to get the same numbers from sklearn.metrics, how to read what the functions return, and where their defaults can mislead you.5 min read
11Chapter 11: Multiclass problems: macro, micro, and weighted averagesPrecision, recall, and F1 are defined for one positive class. A multiclass problem has several classes, so you get one set of numbers per class. This chapter shows how to turn those per-class numbers into a single score, and how the choice of average changes the story the score tells.7 min read
12Chapter 12: Common pitfalls when reporting metricsThis chapter covers the mistakes that make a correct-looking metric misleading. It assumes you can compute accuracy, precision, recall, and F1 from a confusion matrix. It also assumes you know what a train/test split is and can read basic scikit-learn code. Every pitfall below is one where the arith6 min read