Interview conceptMachine Learning

Evaluation Metrics, Calibration, Thresholds, And Ranking

Asked of: Machine Learning Engineer

Last updated

A hierarchical metric tree connects deployment decision quality to classification tradeoffs, calibration, ranking metrics, and production monitoring.

What's being tested

These questions test whether you can choose, implement, and interpret evaluation metrics rather than treating one score as universally correct. The common skill is connecting metric behavior to asymmetric error costs, probability quality, operating thresholds, ranking position, and target-specific loss functions. As an MLE, you must also show that metrics are computed consistently across offline training, validation, deployment, and monitoring, with edge cases and distribution shift handled explicitly. General cares because a model can have excellent aggregate performance while producing unsafe thresholds, misleading probabilities, or poor top-of-list results.

Core knowledge

  • Confusion-matrix tradeoffs separate true positives, false positives, true negatives, and false negatives. Precision is TP/(TP+FP)TP/(TP+FP); recall or TPR is TP/(TP+FN)TP/(TP+FN). A spam filter may prioritize precision, while medical screening commonly prioritizes recall before confirmatory testing.

  • Decision thresholds convert scores or probabilities into actions. With calibrated probability p(x)p(x), predict positive when expected positive-action utility exceeds negative-action utility; under simple costs, choose positive when p(x)>CFP/(CFP+CFN)p(x) > C_{FP}/(C_{FP}+C_{FN}). Thresholds belong on validation data, not the final test set.

  • ROC curves plot TPR against FPR over thresholds and are useful for ranking separability across operating points. Youden’s J is J=TPR−FPRJ=TPR-FPR, selecting the threshold maximizing vertical distance from the diagonal; it implicitly weights sensitivity and specificity equally and does not encode business-specific costs.

  • Precision-recall curves are often more informative than ROC curves for rare positives. ROC AUC can remain high when precision is operationally poor because FPR may look small against a huge negative population; report prevalence, PR AUC, and precision or recall at the actual deployment threshold.

  • Calibration means predicted probabilities match empirical frequencies: among examples assigned probability near 0.70.7, approximately 70% should be positive. Check reliability diagrams, expected calibration error, and Brier score by relevant cohorts; recalibration methods include Platt scaling and isotonic regression.

  • Log loss is −1n∑i[yilog⁡pi+(1−yi)log⁡(1−pi)]-\frac{1}{n}\sum_i[y_i\log p_i+(1-y_i)\log(1-p_i)]. It is a strictly proper, unbounded scoring rule: assigning near-zero probability to an event that occurs is punished severely, making it sensitive to confident mistakes and useful for probabilistic training.

  • Brier score for binary labels is 1n∑i(pi−yi)2\frac{1}{n}\sum_i(p_i-y_i)^2, bounded between 0 and 1. It is also proper and easier to interpret, but its quadratic penalty is less extreme than log loss; decompose it into reliability, resolution, and uncertainty when diagnosing probability quality.

  • NDCG@K evaluates graded ranking quality: DCG@K=∑r=1K2relr−1log⁡2(r+1)DCG@K=\sum_{r=1}^{K}\frac{2^{rel_r}-1}{\log_2(r+1)}, and NDCG@K=DCG@K/IDCG@KNDCG@K=DCG@K/IDCG@K. Compute the ideal ranking using the same KK and relevance labels; return zero when ideal DCG is zero.

  • Ranking implementation should define deterministic tie-breaking, stable sorting, zero-based versus one-based rank conventions, and empty-input behavior. For one query, sorting is typically O(nlog⁡n)O(n\log n) and scoring the top KK is O(K)O(K) afterward; aggregating across queries usually macro-averages per-query NDCG.

  • Quantile pinball loss for quantile τ\tau is ρτ(u)=u(τ−1[u<0])\rho_\tau(u)=u(\tau-\mathbf{1}[u<0]), where u=y−y^u=y-\hat y. It is asymmetric: underpredicting costs τ\tau and overpredicting costs 1−τ1-\tau. Weighted reductions must define whether weights normalize by total weight or sample count.

  • Evaluation slices and parity matter more than a single global number. Compare calibration, recall, false-positive rate, NDCG, and latency across geography, device, language, or traffic source, while preserving a frozen test set; monitor drift in labels, score distributions, prevalence, and metric confidence intervals after release.

Worked example: How do you use Youden's J statistic to pick an operating threshold from a ROC curve?

I would first clarify whether the goal is a symmetric diagnostic operating point or whether false positives and false negatives have different costs, and I would ask which validation population represents production prevalence. I would state that I will generate scores on a held-out validation set, sweep thresholds, compute TPRTPR and FPRFPR, and select the threshold maximizing J=TPR−FPRJ=TPR-FPR. My answer would have four pillars: construct the ROC points correctly, identify the maximum-J threshold, validate its confusion matrix and uncertainty, and confirm that the chosen point satisfies deployment constraints. I would explicitly flag that maximizing J assumes equal importance for sensitivity and specificity, so a medical or abuse-detection system may instead optimize a cost-weighted objective or impose a minimum recall. I would also explain that the test set remains untouched until the threshold and any calibration procedure are frozen. If probabilities are expected to support downstream decisions, I would separately evaluate calibration because ROC performance alone does not guarantee trustworthy probabilities. If I had more time, I would test stability across cohorts and time windows, then monitor threshold performance after deployment as prevalence and score distributions shift.

A second angle: How do log loss and Brier score differ in how they penalize probabilistic errors?

The framing changes from selecting an action threshold to evaluating the entire probability output, so I would ask whether downstream users need calibrated risk or mainly classification discrimination. I would compare both proper scoring rules, emphasizing that log loss is unbounded and heavily punishes confident mistakes, while Brier score is bounded and more interpretable. I would recommend reporting calibration plots and cohort-level results rather than relying on either scalar alone. For a rare-event model, I would also inspect whether the aggregate score is dominated by prevalence and whether a model with better log loss is actually better calibrated in the operating region.

Common pitfalls

Pitfall: “The threshold maximizing Youden’s J is always optimal.” This ignores asymmetric costs, prevalence, capacity limits, and required recall; explain J’s equal-weight assumption and compare it with an explicit cost or constraint.

Pitfall: “A high ROC AUC means the probabilities are reliable.” AUC measures ordering, not calibration; distinguish ranking quality from probability quality and mention reliability diagrams, Brier score, or log loss.

Pitfall: Giving formulas without specifying evaluation protocol is a depth mistake. State the split used for tuning, deterministic tie behavior, zero-positive or zero-ideal-score handling, and how metrics will be monitored after deployment.

Connections

The interviewer may pivot to cost-sensitive learning, probability calibration, precision-recall evaluation under class imbalance, distribution drift, or confidence intervals and bootstrap uncertainty for offline metrics. Ranking metrics can also lead to pairwise losses, learning-to-rank objectives, and online/offline parity.

Further reading

Practice questions

Related concepts