High F1 means both precision and recall are strong.
F1 ignores TN and does not encode financial costs or review capacity.
For the toy fraud detector: \(F1 = 12/(12+4+2) \approx 0.67\).
Summary
Metric
What it measures
High value means
Accuracy
Overall correctness
Model gets most predictions right
Precision
Quality of positive predictions
Small fraction of alerts are false alarms
Recall
Quantity of true positives caught
Small fraction of positives are missed
F1-score
Balance of precision & recall
Both precision and recall are high
iClicker Exercise 9.1
Select all of the following statements which are TRUE.
In screening where a missed disease delays urgent treatment and a false alarm triggers a low-risk follow-up, prioritize precision over recall.
If a spam filter deletes flagged mail, losing a crucial legitimate email can be more costly than letting a spam email reach the inbox (positive = spam).
If method A gets a higher accuracy than method B, that means its precision is also higher.
If method A gets a higher accuracy than method B, that means its recall is also higher.
Counterexamples
Both models see the same 95 negative and 5 positive examples.
Model
Actual class
Predicted negative
Predicted positive
A
Negative
90 (TN)
5 (FP)
A
Positive
5 (FN)
0 (TP)
B
Negative
80 (TN)
15 (FP)
B
Positive
0 (FN)
5 (TP)
Model
Accuracy
Precision
Recall
A
0.90
0
0
B
0.85
0.25
1
Higher accuracy does not guarantee higher precision or recall.
From probabilities to predictions
predict(X) returns a class label: fraud or non-fraud.
predict_proba(X) returns estimated probabilities for each class.
We can choose a threshold: predict fraud when its estimated probability exceeds that value.
Changing the threshold changes the predictions without retraining the model.
Predicting with logistic regression
Move from the medium to the low threshold. Which transactions become TP or FP?
Precision arrows show a tendency, not a guarantee. Scores stay fixed.
Same model, different thresholds
Threshold
Caught (TP)
Missed (FN)
False alarms (FP)
Precision
Recall
F1
0
0.50
71
32
12
0.855
0.689
0.763
1
0.10
82
21
26
0.759
0.796
0.777
2
0.01
88
15
113
0.438
0.854
0.579
Lowering the threshold cannot decrease recall on fixed data. Precision can increase or decrease.
Your turn: can both metrics improve?
Start with TP=6, FP=4, FN=2, TN=88. Lowering the threshold flags three more transactions: two fraud, one legitimate.
ROC plots TPR versus FPR as the threshold varies; the desirable region is top left.
ROC Curve example
Bottom-left\(\rightarrow\) very high threshold (almost everything predicted negative: low recall, low FPR).
Top-right\(\rightarrow\) very low threshold (almost everything predicted positive: high recall, high FPR).
ROC AUC
The area under the ROC curve (AUC) represents the probability that the model, if given a randomly chosen positive and negative example, will rank the positive higher than the negative (ties count as half).
For example, AUC-ROC = 0.90 means: If we randomly pick one fraudulent transaction and one legitimate transaction, there’s a 90% chance the model assigns a higher fraud score to the fraudulent transaction, with ties counted as half.
Why a small FPR can still mean many false alarms
Suppose 100 of 100,000 transactions are fraud.
At 80% recall and 1% FPR:
Fraud caught: 80.
Legitimate transactions flagged: 999.
Precision: \(80/(80+999) \approx 7.4\%\).
PR shows alert reliability; ROC shows the fraction of negatives affected. Both are useful with imbalanced data. Inspect the operating region and counts.
Exercise 9.4: which model?
The review team wants to catch at least 80% of positive cases (recall ≥ 0.8) while keeping false alarms as low as possible (maximizing precision).
Model
AP
Best validation precision meeting the requirement
A
0.90
0.50
B
0.86
0.70
Questions:
Which model would you choose for this application?