import numpy as np
from sklearn.metrics import confusion_matrix
probabilities = model.predict_proba(X_valid)[:, 1]
thresholds = np.linspace(0.1, 0.9, 9)
for threshold in thresholds:
predictions = (probabilities >= threshold).astype(int)
tn, fp, fn, tp = confusion_matrix(y_valid, predictions).ravel()
print({
'threshold': round(float(threshold), 2),
'tp': int(tp),
'fp': int(fp),
'fn': int(fn),
'tn': int(tn),
})
Thresholds are policy decisions disguised as numbers. I use confusion matrices to make those tradeoffs concrete for stakeholders: how many risky accounts we block, how many fraud attempts slip through, and how much manual review load is created. This is often where model work turns into operational design.