liveBook · Manning

Accuracy

As explained in Grokking Machine Learning

A classification metric equal to the proportion of evaluated data points for which the predicted label matches the correct label.

How often does a classifier get the label right? Accuracy answers by counting correct predictions and dividing by the number of evaluated data points: accuracy = correct predictions / total predictions. If a model labels 875 of 1,000 test samples correctly, its accuracy is 0.875, or 87.5%. section 7.1

For a two-label problem, correct predictions are true positives plus true negatives. A confusion matrix also shows the mistakes—false positives and false negatives—that the single accuracy number combines. section 7.2

When 99% is not good enough

Imagine 1,000 patients: 10 are sick and 990 are healthy. A model that calls everyone healthy gets 990 predictions right, so its accuracy is 99%. But it misses every sick patient. High accuracy can therefore hide a serious failure when one label is much less common than the other. section 7.1 section 7.2

Table 7.2 The confusion matrix of our coronavirus model helps us dig into our model and tell the two types of errors apart. This model makes 10 false negative errors (a sick person diagnosed healthy) and zero false positive errors (a healthy person diagnosed sick). Notice that the model creates too many false negatives, which are the worst type of error in this case, which implies that this model is not very good. (view table figure)

Coronavirus model 1

Diagnosed sick (predicted positive)

Diagnosed healthy (predicted negative)

Sick (positive)

0 (number of true positives)

10 (number of false negatives)

Healthy (negative)

0 (number of false positives)

990 (number of true negatives)

Read across the sick row: all 10 sick patients were diagnosed healthy, despite the model’s 990 correct predictions. section 7.2

Use accuracy as a starting point, then check which errors matter. Recall draws attention to missed positive cases, such as sick patients diagnosed healthy; precision draws attention to incorrect positive predictions, such as ordinary email marked as spam. A validation set can help compare candidate models, followed by evaluation on a test set. section 7.4 section 13.4

Try a small comparison

For each of two app-recommendation rules, count how many of six users receive the app they downloaded. Splitting users by platform gets four right; splitting by age gets five right. Their accuracies are 4/6 and 5/6, so age wins by this measure. section 9.2

How Grokking Machine Learning covers it

How deep it goes
Defines a correct-prediction ratio, works through counts, and examines misleading results; defers error-sensitive judgments to other metrics.
Examples
Uses patient diagnoses, spam emails, app recommendations, and a video-recommendation exercise.
What it assumes
Assumes data points have correct labels and model predictions; introduces the accuracy ratio and error categories directly.
What you can do after
Evaluate/understand it by calculating accuracy, comparing classifiers, and checking whether high accuracy conceals important errors.
How it connects
Connects accuracy to confusion matrices, false positives, false negatives, recall, precision, and decision trees.

Also explained in

Compare how 32 books explain accuracy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning. The section links point to the parts of the book it draws on.