Can you handle class imbalance without changing the data? What is threshold tuning?
Yes. Most classifiers output a probability, and the default cut-off of 0.5 is arbitrary. Lowering it for a rare class raises recall at the cost of precision. Pick the threshold from the precision-recall curve using business costs.
Explain it simply
A doctor deciding whether to order a further test for a rare disease does not wait until she is 50% sure. Missing the disease is costly, so she orders the test at, say, 10% suspicion. The model's cut-off can behave the same way.
The model's job is to rank cases by risk. The threshold is a separate business decision about how much risk is enough to act.
Example
A model scores six transactions; the true frauds are marked.
score true label
0.90 fraud
0.60 fraud
0.45 legit
0.40 fraud
0.20 legit
0.05 legit
Threshold 0.5: flags 2 -> TP=2, FP=0, FN=1 precision 1.00, recall 0.67
Threshold 0.3: flags 4 -> TP=3, FP=1, FN=0 precision 0.75, recall 1.00Lowering the threshold from 0.5 to 0.3 caught the extra fraud (recall 2/3 to 3/3) but flagged one genuine payment (precision 2/2 to 3/4).
probs = model.predict_proba(X_val)[:, 1]
pred = (probs >= 0.3).astype(int)Choose the threshold on validation data, then check it once on the test set.
What to say in the interview
"I treat the probability as a ranking and tune the threshold for the business trade-off between false alarms and misses, using the precision-recall curve on validation data. It needs no resampling and works with any probabilistic model, though the probabilities should be reasonably calibrated."
Common mistakes
- Tuning the threshold on the test set.
- Assuming 0.5 is always right.