In a binary classification model, what happens to the precision and recall when you increase the decision threshold from 0.5 to 0.8?
Think about how raising the threshold affects which predictions are labeled positive.
Increasing the threshold means the model is more strict to label positives, so fewer false positives occur, increasing precision. But some true positives are missed, lowering recall.
What is the output of the following Python code that applies threshold tuning on model probabilities?
import numpy as np probs = np.array([0.2, 0.6, 0.8, 0.4, 0.9]) threshold = 0.7 preds = (probs >= threshold).astype(int) print(preds.tolist())
Check which probabilities are greater than or equal to 0.7.
Only 0.8 and 0.9 are >= 0.7, so their predictions are 1; others are 0.
You have a highly imbalanced dataset with very few positive cases. Which threshold tuning strategy is best to maximize recall while keeping false positives reasonable?
Recall is about catching positives; think about how threshold affects it.
Lowering threshold increases recall but may increase false positives. Using precision-recall curve helps find a good trade-off.
Given a model with these confusion matrix values at threshold 0.5: TP=40, FP=10, FN=20, TN=130. If threshold is increased to 0.7, TP=30, FP=5, FN=30, TN=135. What happens to the F1 score?
Calculate precision and recall for both thresholds, then compute F1.
At 0.5 threshold: precision=40/(40+10)=0.8, recall=40/(40+20)=0.67, F1≈0.73. At 0.7 threshold: precision=30/(30+5)=0.86, recall=30/(30+30)=0.5, F1≈0.63. F1 decreases.
Consider this Python code snippet for threshold tuning. It produces unexpected predictions. What is the cause?
import numpy as np probs = np.array([0.3, 0.7, 0.5, 0.9]) threshold = 0.5 preds = (probs > threshold).astype(int) print(preds.tolist())
Check how the comparison operator affects predictions equal to threshold.
The code uses '>' which excludes probabilities exactly equal to 0.5, so those are predicted negative. Using '>=' includes them.