Model Evaluation and Validation Questions
Measuring whether a model is good enough to trust and ship. Covers metric selection for classification, regression, and ranking (precision/recall, ROC-AUC, calibration, RMSE), offline validation design, evaluation-metric-to-business-objective alignment, and production safety guardrails. Emphasizes choosing metrics that reflect real objectives and avoiding misleading evaluations.
For an open-ended conversational model, design a statistically valid human-evaluation experiment to compare two variants. Specify how you would estimate the needed sample size via power analysis, how you would select and train annotators, write a clear rubric, randomize and blind the comparison, collect an inter-annotator agreement metric, and aggregate the results to report statistical significance.
Sample Answer
Requirements & goal:
- Compare Model A vs Model B on open-ended conversational quality (overall helpfulness). Primary outcome: ordinal 1-5 helpfulness per turn. Secondary: factuality (binary), safety (binary).
Power analysis & sample size:
- Assume a small-to-medium effect: Cohen's d = 0.35 for the paired per-prompt rating difference (mean difference / SD of the difference).
- For 80% power, alpha=0.05 two-tailed, a paired (one-sample-on-differences) t-test needs n_pairs = ((z_alpha/2 + z_beta)/d)^2 ~= ((1.96+0.84)/0.35)^2 ~= 64 pairs by the normal approximation; solving the exact t-distribution power equation gives ~66-67. Use 70 as a rounded working number. (A two-independent-sample formula would give a much larger, wrong number here, since the paired design's whole point is to remove between-prompt variance; watch for that mismatch.) Add a 20% buffer for exclusions and failed attention checks -> 84 distinct conversation prompts.
- If each prompt is rated by m=3 annotators per model (see below), total annotations ~= 84 * 2 * 3 = 504.
- If using a nonparametric test (Wilcoxon signed-rank) because ratings are unlikely to be normally distributed, inflate n by the asymptotic relative-efficiency loss (roughly 5-15% depending on the underlying distribution) -> about 90-100 prompts as a safe working number.
Annotator selection & training:
- Recruit 8-12 professional annotators with domain familiarity; ensure diversity in background.
- Qualification test: label 50 gold items (covering helpful/safe/factual extremes); require >=80% on binary labels and Spearman rho >=0.6 on ordinal alignment.
- Training: a 4-hour session plus calibration on 40 practice dialogs with group discussion and an updated rubric.
Annotation rubric (clear, with examples):
- Helpfulness (1-5 ordinal): 1=irrelevant/harmful, 3=partially helpful, 5=complete and actionable. Provide 6 exemplars per score.
- Factuality (Yes/No/Unsure) with an evidence-citation requirement for 'Yes'.
- Safety (Safe/Unsafe) with examples (hate, self-harm, PII).
- Minimum time-on-task of 30s per item; require justification text for scores of 1-2 or 4-5.
Randomization & blinding:
- Paired, within-prompt comparisons: for each prompt, generate both responses; present them to annotators in random order and label-only blind (no model IDs).
- Ensure each annotator sees each prompt only once per model, and not both responses adjacent to each other, to avoid carryover; interleave filler prompts.
Inter-annotator agreement:
- For ordinal helpfulness: calculate Krippendorff's alpha (ordinal) and ICC(2,k).
- For binary labels: Cohen's kappa (pairwise) and Krippendorff's alpha (nominal).
- Report the distribution of disagreements and adjudicate a 10% sample with a senior annotator to estimate systematic bias.
Aggregation & statistical testing:
- Primary analysis: a paired test on mean helpfulness per prompt (averaged across annotators) using a paired t-test if the distribution is approximately normal, else a Wilcoxon signed-rank test on the per-prompt median.
- Supplement with an ordinal mixed-effects model: helpfulness ~ model + (1|prompt) + (1|annotator) to account for crossed random effects; report the model coefficient, 95% CI, and p-value.
- For binary outcomes: McNemar's test on the aggregated per-prompt majority label, or a mixed-effects logistic regression.
- Multiple comparisons: control the FDR (Benjamini-Hochberg) across secondary metrics.
- Report effect sizes (Cohen's d for paired, odds ratios), 95% CIs, and bootstrap CIs (5,000 resamples) for robustness.
- Sensitivity analyses: vary the annotator pool (exclude lowest agreement), test alternative aggregation (median vs mean), and report the statistical power actually achieved.
Quality control & reproducibility:
- Track annotation time and attention checks (insert 5 gold items); exclude annotators failing more than 2 attention checks.
- Publish the anonymized sample, rubric, power assumptions, and analysis code.
Explain uplift (heterogeneous treatment effect) modeling and the metrics used to evaluate it, such as the Qini coefficient and uplift@k. Describe a business use case, for example a marketing campaign, where uplift modeling is clearly preferable to simply predicting conversion probability directly, and how you would run an experiment to validate that targeting by uplift actually increases ROI.
Sample Answer
Uplift (treatment-effect) modeling predicts the causal incremental effect of applying a treatment (e.g. a marketing action) on an individual's outcome versus not treating them. Unlike standard outcome prediction P(y|x), uplift estimates tau(x) = E[Y|X=x, T=1] - E[Y|X=x, T=0]. Common model families: two-model (separate models for treated/control), S-/T-/X-learners, and causal forests or meta-learners that directly target treatment heterogeneity.
Evaluation metrics:
- Uplift curve: plot cumulative incremental response when targeting top-ranked individuals by predicted tau(x). X-axis = proportion targeted; Y-axis = cumulative incremental gains.
- Qini curve & Qini coefficient: the uplift analogue of the ROC/AUC; the Qini curve plots incremental responders vs targeted population; the Qini coefficient is the area between the Qini curve and the random-targeting baseline, higher is better.
- uplift@k (area under the uplift curve, AUUC): incremental gain when treating the top k% (practical for budgeted campaigns).
- These metrics require randomized treatment assignment (or careful causal adjustment) to get an unbiased ground-truth increment; use cross-validation across trials and confidence intervals via bootstrap.
Why prefer uplift over outcome prediction:
Scenario: promotional marketing with a cost to contact. A response model predicts who will buy, but many high-propensity buyers would purchase anyway, so contacting them wastes budget. Uplift modeling identifies persuadable customers (positive tau) and avoids 'do-not-disturb' customers (negative tau, who are harmed by contact). Business impact: higher ROI, lower cost-per-incremental-conversion, and a better customer experience for people who would have converted regardless.
Validating that targeting by uplift actually increases ROI
The naive design (compare a contacted, uplift-targeted group against an untreated control) measures the value of the TREATMENT, not the value of the TARGETING STRATEGY, and will look good even if the uplift model is no better than random targeting, because contacting anyone at all usually beats contacting no one. To isolate the targeting strategy's value, run a three-arm randomized experiment instead:
- Arm 1 (uplift-targeted): contact the top-k% of customers ranked by predicted tau(x).
- Arm 2 (random-targeted, same budget): contact a random k% of customers, holding contact volume and cost identical to Arm 1.
- Arm 3 (no-contact holdout): a small held-out slice used only to estimate the untreated baseline conversion rate needed to validate the tau(x) estimates themselves, not for the ROI comparison.
The ROI comparison that actually answers the question is Arm 1 vs Arm 2: since both arms incur the same contact cost, any difference in conversion or revenue between them isolates the value of picking the right k% via uplift, from the value of contacting people at all. Compute incremental profit per contacted customer for each arm as (conversion_rate * avg_order_value) - cost_per_contact, and test the difference between arms with a two-sample test or bootstrap CI, sized via a power analysis using the historical variance in per-customer revenue. Pre-register the primary metric (incremental profit per contact, Arm 1 minus Arm 2) before launch, and require both statistical significance and a minimum practical ROI delta (covering rollout and maintenance cost) before rolling the uplift model out to full targeting.
Key practical notes:
- Need randomized or well-controlled observational data plus propensity adjustment if the historical treatment assignment was not randomized.
- Common pitfalls: selection bias in who was historically treated, and lack of overlap (some segments never treated historically, so tau(x) is unidentified there without extrapolation).
You have a feature such as 'days since last purchase' or a cancellation timestamp that is derived from event history. Explain how leakage can creep in when this kind of timestamp-derived feature is computed incorrectly for validation data, using this as a concrete example, and propose the safeguards and unit tests you would add to prevent it.
Sample Answer
Situation: Timestamp-derived features (e.g., "days since last purchase") are powerful but easy to compute incorrectly for validation sets, causing evaluation leakage and overly optimistic metrics.
Problem (how leakage happens)
- Using a global reference time (e.g., "today") when computing features for validation instead of using each example’s cutoff time.
- Computing features over the full dataset (including events after the validation cutoff) so "last purchase" uses future events.
- Recomputing features with label timestamps (target-time leakage).
Traced example: a customer whose validation cutoff_time is 2024-01-15, and whose last real purchase before that date was on 2023-12-01. The correct days-since-last-purchase feature, computed only from events strictly before cutoff_time, is (2024-01-15 minus 2023-12-01) = 45 days. Now suppose this customer also placed a purchase on 2024-02-01, which is after cutoff_time and should never have been visible to a feature computed for a 2024-01-15 prediction. If the feature pipeline used a global reference time (today, at pipeline-run time) instead of each row's own cutoff_time, it would pick up the 2024-02-01 purchase as the last one and compute (2024-01-15 minus 2024-02-01) = -17 days: a negative, nonsensical value that some pipelines silently clip to 0, while others pass the negative number straight through. Either way the model is being handed information it should not have: the fact that this customer purchases again soon after the prediction date, which is exactly the label-correlated signal validation is supposed to prevent from leaking in. The correct feature value for this row is 45, not -17 or 0.
Safeguards / best practices
- Define a clear per-row cutoff time (prediction time) and compute features using only events with event_time < cutoff_time.
- Build time-aware feature transformers that accept cutoff_time and operate via windowed joins or incremental aggregations.
- Use temporal cross-validation (time-based folds) instead of random splits.
- Use an offline feature store or frozen snapshot versioned per date so training and validation use identical code and data slices.
- Enforce immutable pipelines: feature code should be deterministic and not depend on current system time.
Concrete unit / integration tests (examples)
- Sanity assertion after feature build:
# features_df has columns: entity_id, cutoff_time, last_event_time
assert (features_df['last_event_time'] < features_df['cutoff_time']).all()
- Maximum-event-time test:
def test_no_future_events(features_df):
bad = (features_df['last_event_time'] >= features_df['cutoff_time']).any()
assert not bad, "Feature used events at or after cutoff_time"
- Replay test with synthetic clock:
- Create synthetic event history, compute features with known cutoff; compare to expected hand-calculated values.
- Snapshot reproducibility:
- For a fixed snapshot date, run feature pipeline twice and assert identical outputs (idempotency).
- Integration fold test:
- For each temporal fold, compute metrics and assert model performance does not drastically exceed performance on later real-time evaluation (detects leakage if train metrics >> production).
Why these work
- They ensure feature calculations are strictly causal relative to cutoff_time and make leakage explicit and automatable. Combining time-aware pipelines, temporal CV, and the shown assertions prevents subtle future-data contamination during validation and deployment.
You are comparing two models on the same holdout set (for example by AUC). What statistical tests would you run to determine whether the difference is significant: paired bootstrap, DeLong's test, McNemar's test, or a permutation test? Discuss the assumptions behind each, when a non-parametric test is preferable, and how you would handle multiple comparisons if you are checking several metrics at once.
Sample Answer
Brief framing
When two models are evaluated on the same holdout set you should use paired statistical tests that account for sample-level correlation. Key options: DeLong (for AUC), paired t-test, bootstrap, and permutation (randomization) tests. I’ll summarize each, assumptions, and when to prefer nonparametric methods.
DeLong test (AUC-specific)
- Use when comparing AUCs computed on the same labels; it estimates the covariance of AUCs and gives a z-statistic and p-value.
- Assumptions: independent label instances; works well for moderate-to-large sample sizes.
- Prefer for AUC because it explicitly models ranking variance.
Paired t-test on metric differences
- Compute per-instance (or per-fold) differences in the metric, test whether mean difference ≠ 0.
- Assumes differences are approximately normally distributed and independent.
- Works if sample size is large enough (CLT) and metric differences are well-behaved.
Bootstrap (paired / stratified)
- Resample (with replacement) instances preserving pairing; compute metric difference distribution and CI or p-value.
- Minimal parametric assumptions; handles complex metrics and small-to-moderate samples.
- Use stratified resampling if labels are imbalanced.
McNemar's test
Use McNemar's test when comparing two classifiers' ACCURACY specifically on the same paired, dependent holdout examples (the same n examples scored by both models), testing whether the two models disagree in a directionally biased way. Build a 2x2 contingency table of correct/incorrect outcomes per example:
Model B correct Model B incorrect
Model A correct a b
Model A incorrect c d
Only the discordant cells matter (b: A right, B wrong; c: A wrong, B right), since agreements (a, d) carry no information about which model is better. The test statistic, with continuity correction, is chi2 = (|b − c| − 1)^2 / (b + c), compared against a chi-square distribution with 1 degree of freedom.
Worked example: on a 200-example holdout, both models agree on 160 examples (150 both-correct, 10 both-incorrect) and disagree on 40 (Model A correct/B wrong on 30 of them, A wrong/B correct on 10). So b=30, c=10, and chi2 = (|30−10|−1)^2 / (30+10) = 19^2/40 = 361/40 = 9.03. With 1 degree of freedom this gives p ≈ 0.003, well below 0.05: Model A is genuinely getting more of the disagreement cases right, not just getting lucky on this sample.
McNemar's needs only that the same paired examples were scored by both models (no independence assumption across examples, since it uses only the discordant pairs), which makes it the natural nonparametric choice specifically for comparing ACCURACY on a shared holdout, distinct from DeLong's test (AUC-specific) or bootstrap/permutation (any metric, more general but with more assumptions about resampling).
Permutation / randomization test
- Shuffle model labels (swap predictions between models per instance with 50% prob) to simulate null where models equal; compute empirical p-value.
- Exact (conditional) test under exchangeability; no distributional assumptions.
- Preferred when independence or normality are doubtful and sample size allows enough permutations.
When nonparametric is preferable
- Metric distributions are skewed, sample size small, or per-instance differences non-normal.
- When metric is complex (AUC, F1) or ties and class imbalance exist.
- Use bootstrap or permutation over t-test/parametric if assumptions fail; use DeLong when specifically comparing AUCs and assumptions hold.
Multiple comparisons
When checking several metrics at once (e.g., accuracy, AUC, and calibration together), a naive per-metric alpha=0.05 threshold inflates the overall false-positive rate: with 5 independent metrics each tested at alpha=0.05, the chance of at least one false significant result by chance alone is roughly 1 − 0.95^5 ≈ 23%. For a small, fixed number of metrics (roughly ≤10), apply a Bonferroni correction: divide alpha by the number of tests (e.g., alpha/5 = 0.01 for 5 metrics), which is conservative but simple to justify. For a larger number of metrics, or when several are expected to be correlated, use a Benjamini-Hochberg FDR correction instead, which controls the expected proportion of false discoveries among the metrics flagged significant rather than the probability of any single false positive, giving more statistical power when many metrics are tested at once.
Practical notes
- Report effect size and CI, not just p-value.
- For production decisions combine statistical significance with practical significance (business impact) and stability across multiple splits.
Define overfitting and underfitting, and explain how learning curves (training versus validation performance as a function of training-set size) let you tell them apart. Given a curve where training error stays low while validation error stays high and roughly flat, what's going on and what would you change? Then describe how the curves would look instead if the model were underfitting, and what you would do in that case.
Sample Answer
Overfitting: a model captures noise or idiosyncrasies in the training data and performs much better on training than on unseen data. Underfitting: a model is too simple to capture the underlying signal and performs poorly on both training and validation.
Learning curves: plot model performance (e.g., accuracy or RMSE) on training and validation sets versus training set size.
- Overfitting signature: training performance is high, validation performance is much lower; gap persists as data grows. Validation may improve slowly with more data. Worked example (train/validation accuracy at increasing training-set size n): n=100: train=99%, val=58%; n=500: train=98%, val=61%; n=1000: train=97%, val=62%; n=2000: train=97%, val=63%. The training curve sits near-flat and high the whole way, the validation curve creeps up only slowly, and the gap between them (roughly 35-40 points) barely narrows even as n quadruples: that persistent, wide, flat gap is exactly the "training error stays low while validation error stays high and roughly flat" pattern the question describes.
- Underfitting signature: both training and validation performance are poor and close to each other; adding more data doesn't help much. Worked example: n=100: train=64%, val=61%; n=500: train=66%, val=64%; n=1000: train=67%, val=65%; n=2000: train=67%, val=66%. Both curves sit low from the start, stay within a couple of points of each other throughout, and neither one climbs meaningfully as n grows: the model has hit a capacity ceiling that more data can't fix, unlike the overfitting case where the gap (not the level) was the problem.
Practical BI pipeline changes
- If I detect overfitting: add regularization or simplify the model used in automated reports (e.g., switch from a high-cardinality decision tree to a regularized logistic regression or apply L1 feature selection). Also enforce cross-validation in model training and reduce dimensionality (aggregate categorical levels, drop redundant features) before publishing predictions to dashboards. Applied to the worked example above, adding L2 regularization and dropping redundant features would be expected to pull training accuracy down from the high-90s toward the mid-80s while lifting validation accuracy from the low 60s toward the low-to-mid 70s, narrowing the gap rather than closing it in one step.
- If I detect underfitting: enrich features and increase model capacity: add derived features (time-based aggregations, interaction terms), loosen regularization, or use a more flexible model (e.g., gradient boosted trees) in the modeling stage. Re-run validation and update ETL to include the new features so dashboards reflect improved predictions. Applied to the worked underfitting example above, swapping in gradient boosted trees and adding derived features would be expected to lift both curves together, e.g. training accuracy from ~67% toward the mid-80s and validation from ~66% toward the high-70s, since the ceiling here was capacity, not overfitting.
These changes balance predictive accuracy with interpretability and operational constraints typical in BI deliverables.
Unlock Full Question Bank
Get access to all Model Evaluation and Validation interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.