Lesson 2 · Unit 03
Metrics
Confusion matrix, F1, AUC and errors for numbers
What you practise
- The confusion matrix, precision, recall and F1 from counts, why accuracy lies on imbalanced classes, the ROC curve and AUC as a ranking score, MAE, RMSE and R² for regression
Try a question from this lesson
Pick one
1,000 transactions hold 10 frauds. Model A flags 20, of which 8 are fraud. Model B flags 100, of which 10 are fraud. Which statement is true?
Hint
For each model: what share of its flags are real, and what share of the frauds did it find?
Correct answer
A wastes fewer flags; B misses fewer frauds
Why
A is right on 8 of 20 flags (40%) but finds only 8 of the 10 frauds. B is right on 10 of 100 flags (10%) but finds every fraud. That is precision against recall, and no single number settles it without the costs.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
The confusion matrix
Every prediction of a yes/no model lands in one of four boxes.
True positive (TP): flagged, and really positive. False positive (FP): flagged, but negative. False negative (FN): a positive that was missed. True negative (TN): correctly left alone.
Every metric in this lesson is a ratio of these four counts.
predicted
yes no
actual yes TP FN
actual no FP TNConcept
Ranking: ROC and AUC
Precision and recall depend on the threshold. To judge the scores themselves, sweep the threshold from high to low and plot the true-positive rate against the false-positive rate: the ROC curve.
The area under it (AUC) equals the chance that a random positive gets a higher score than a random negative. 1.0 is a perfect ranking; 0.5 is a coin flip.
10 more exercises in the app
- 3× type the answer
- 1× fill the blanks
- 4× multiple choice
- 1× match the pairs
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.