← AI / ML Foundations
12 / 25
Lesson 12 — Accuracy
Did the model do well? Accuracy
For a classifier (a model that picks a class like 0 or 1) the simplest score is accuracy: the share of predictions that match the true labels (the correct answers). 4 correct out of 5 is 0.8, or 80%.
preds = [1, 0, 1]
labels = [1, 1, 1]
# correct = 2, accuracy = 2 / 3
Watch out: accuracy can lie. If 99% of emails are not spam, a model that always says "not spam" scores 99% and is useless. Lesson 17 shows a better view.
Why it matters: accuracy is the first number everyone asks about — know how to compute it and when not to trust it.
Want it another way?
Task
Count the predictions that equal their label, then compute accuracy. Expected: correct 4, accuracy 0.8.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.