76 Model Evaluation Interview Questions and Answers (2026)

Blog / 76 Model Evaluation Interview Questions and Answers (2026)
Model Evaluation interview questions and answers

Anyone can train a model that posts 0.98 accuracy offline. The hard part is knowing whether that number means anything, and interviewers now probe exactly that: leaky splits, misleading aggregates, uncalibrated probabilities, and offline gains that die in production. Walk in with surface-level metric definitions and you'll get exposed by the first follow-up.

This guide gives you 76 questions with concise, interview-ready answers, plus code where it helps. They're ordered Junior → Mid → Senior, so you start with data splits and confusion matrices and work up to calibration, fairness slicing, and significance testing. Work through them in order and you'll walk in ready to reason, not recite.

Q1.
Why should random train/test splits not be used for time-series data?

Junior

Random splits put future observations in the training set and past ones in the test set, so the model effectively peeks at the future. This leaks information through temporal correlation and gives an optimistic estimate that won't hold when forecasting truly unseen future data.

  • Temporal leakage:

    • Adjacent time points are highly autocorrelated; with random splits, a test point's neighbors (before and after) are in training, making interpolation easy.

    • Features like rolling averages or lag windows can encode future values if computed across the split.

  • Doesn't mimic deployment:

    • In production you always train on the past and predict the future; evaluation should reproduce that.

    • Random splits also hide concept drift, since train and test share the same time mix.

  • What to do instead:

    • Chronological holdout: train on earlier periods, test on the latest.

    • Walk-forward / expanding-window CV (e.g. TimeSeriesSplit in scikit-learn).

    • Add a gap (embargo) between train and test when labels or features span a window, to prevent overlap leakage.

python
from sklearn.model_selection import TimeSeriesSplit tscv = TimeSeriesSplit(n_splits=5, gap=7) # each fold: train on past, test on next block for train_idx, test_idx in tscv.split(X): model.fit(X[train_idx], y[train_idx]) score = model.score(X[test_idx], y[test_idx])

Q2.
Why is a metric measured on data used for tuning optimistically biased?

Junior

When you pick hyperparameters, models, or thresholds by maximizing a score on some data, you are selecting the configuration that fits that particular sample best, including its noise. The winning score is therefore inflated relative to what the model would achieve on fresh data.

  • Selection on noise (winner's curse):

    • Each candidate's validation score = true performance + random error. Taking the max favors candidates with lucky positive error.

    • The more configurations you try, the larger the expected optimism.

  • Indirect fitting:

    • Tuning is a form of training: information from the tuning data flows into the model's choices, so that data is no longer independent.

    • Repeatedly checking the test set and adjusting does the same thing ("test set overfitting").

  • Remedies:

    • Keep a held-out test set touched only once for the final estimate.

    • Use nested cross-validation: inner loop tunes, outer loop estimates performance of the whole tuning procedure.

    • Limit the number of comparisons and report confidence intervals.

Q3.
Why should baseline models like majority class, heuristics, or the previous production model always be evaluated before complex models?

Junior

Baselines give a metric meaning: a score is only good or bad relative to what simple alternatives achieve. They reveal whether the problem is trivially solvable, catch bugs and leakage, and determine whether a complex model's extra cost is justified.

  • Calibrate the metric:

    • Majority-class baseline exposes imbalance: 99% accuracy is worthless if 99% of labels are negative.

    • Random or prior-rate baselines anchor AUC (0.5) and PR-AUC (positive rate).

  • Measure real value added:

    • Heuristics (rules, last value, popularity, linear/logistic regression) often capture most of the signal.

    • If a deep model beats them by a hair, the gain may not justify latency, cost, maintenance, and reduced interpretability.

  • Previous production model is the real bar:

    • Launch decisions hinge on improvement over what is live, evaluated on the same data and slices.

    • Guards against regressions on important segments.

  • Sanity and debugging:

    • A complex model underperforming a simple one signals bugs in the pipeline, features, or training.

    • A complex model wildly outperforming every baseline is a red flag for leakage.

    • Baselines are fast to build, so they also validate the evaluation pipeline early.

Q4.
What is the difference between an evaluation metric and a loss function?

Junior

A loss function is what the training algorithm optimizes, so it must be differentiable (or otherwise tractable) and is computed per example. An evaluation metric is what humans use to judge whether the model is good for the task; it should reflect the business goal and need not be optimizable.

  • Loss function:

    • Used during training to compute gradients: cross-entropy, MSE, hinge loss.

    • Chosen for mathematical properties: smoothness, convexity, good gradients, probabilistic interpretation.

  • Evaluation metric:

    • Used for model selection and reporting: accuracy, F1, AUC, precision@k, BLEU, revenue lift.

    • Often non-differentiable (thresholded counts, rankings) or defined over the whole dataset, not per example.

  • How they relate:

    • The loss is a surrogate for the metric: minimizing log loss usually improves accuracy, but not guaranteed.

    • Sometimes they coincide (MSE as both loss and metric for regression).

    • Gaps are bridged by threshold tuning, class weights, or surrogate losses designed for the metric (e.g. ranking losses for NDCG).

Q5.
Why do we need a validation set in addition to a test set?

Junior

The validation set is used to make decisions (hyperparameters, model choice, early stopping, thresholds), which makes its score optimistically biased. The test set is kept untouched so it gives an unbiased estimate of how the final chosen model will perform on new data.

  • Validation set: for development:

    • Compare candidate models and tune hyperparameters without using training data (which would favor overfitting).

    • Every decision based on it leaks information, so its score becomes part of the fitting process.

  • Test set: for final assessment:

    • Used once, after all choices are frozen, to report expected generalization.

    • If you tune on it, it silently becomes another validation set and the reported number is inflated.

  • Practical variants:

    • With limited data, replace the fixed validation set with k-fold cross-validation on the training portion, still holding out a test set.

    • Nested CV provides an unbiased estimate when a separate test set is too costly.

Q6.
How do you decide whether to optimize for precision or recall in a specific business problem?

Junior

Decide based on the relative cost of the two error types: optimize recall when missing a positive (false negative) is expensive, and precision when acting on a wrong positive (false positive) is expensive. In practice you translate costs into a threshold or a constraint, not a pure choice of one metric.

  • Favor recall when false negatives hurt most: Cancer screening, fraud detection, safety/abuse flagging: a miss is costly, and a false alarm only triggers a cheap review.

  • Favor precision when false positives hurt most: Spam filtering (losing a real email), auto-banning users, top-k recommendations: wrong actions damage trust or cost money.

  • Make it concrete:

    1. Estimate the cost of a FP and a FN (money, user harm, review workload).

    2. Plot the precision-recall curve and choose the threshold that minimizes expected cost.

    3. Or frame as a constraint: maximize recall subject to precision ≥ X (e.g. review-team capacity), or vice versa.

    4. If both matter similarly, use F1 or F-beta (beta > 1 weights recall more).

  • Check downstream workflow: A human-in-the-loop stage tolerates lower precision; fully automated actions usually need high precision.

Q7.
Why is accuracy a misleading metric on imbalanced datasets?

Junior

Accuracy counts all correct predictions equally, so when one class dominates, a model can score highly by just predicting the majority class while completely failing on the minority class, which is usually the one you care about.

  • The trivial baseline trap:

    • With 99% legitimate transactions, "always predict legit" gets 99% accuracy and catches zero fraud.

    • Accuracy improvements may only reflect better majority-class predictions.

  • It ignores error asymmetry: A missed fraud and a false alarm count the same, though their costs differ greatly.

  • Better alternatives:

    • Confusion matrix plus precision, recall, and F1 for the minority class.

    • PR-AUC (more informative than ROC-AUC under heavy imbalance, since ROC's false positive rate stays small when negatives are huge).

    • Balanced accuracy or Matthews correlation coefficient for a single summary number.

    • Cost-weighted metrics when error costs are known.

Q8.
What is specificity, how does it relate to the false positive rate, and in what real-world domain is it prioritized?

Junior

Specificity (true negative rate) is the fraction of actual negatives correctly identified as negative. It is the complement of the false positive rate: specificity = 1 − FPR. It is prioritized where false positives are costly, classically in confirmatory medical testing.

  • Formulas:

    • Specificity = TN / (TN + FP)

    • FPR = FP / (FP + TN) = 1 − specificity

    • It is "recall for the negative class"; its counterpart is sensitivity (recall for positives).

  • Relation to ROC: The ROC curve plots sensitivity vs 1 − specificity (FPR) across thresholds.

  • Where it is prioritized:

    • Medicine: confirmatory tests (e.g. before surgery or chemotherapy) need high specificity so healthy people aren't wrongly treated. Screening tests favor sensitivity, then a high-specificity test confirms.

    • Also: criminal justice / forensic matching, spam filtering, fraud blocks that freeze legitimate accounts.

  • Caveat: specificity is insensitive to class imbalance, so with rare positives a 99% specificity can still mean most alerts are false; check precision too.

Q9.
How do you derive accuracy, precision, and recall from a confusion matrix?

Junior

A binary confusion matrix has four cells: TP, FP, FN, TN. Accuracy uses all of them. Precision divides TP by its predicted-positive column, and recall divides TP by its actual-positive row.

  • The cells:

    • TP: predicted positive, actually positive. FP: predicted positive, actually negative.

    • FN: predicted negative, actually positive. TN: predicted negative, actually negative.

  • Formulas:

    • Accuracy = (TP + TN) / (TP + FP + FN + TN): fraction of all predictions that are correct.

    • Precision = TP / (TP + FP): of everything flagged positive, how much was right.

    • Recall = TP / (TP + FN): of all real positives, how many were caught (also called sensitivity or TPR).

  • Worked example: TP=40, FP=10, FN=20, TN=930:

    • Accuracy = 970/1000 = 0.97. Precision = 40/50 = 0.80. Recall = 40/60 ≈ 0.67.

    • The high accuracy comes mostly from the many TNs, which is why precision and recall matter on imbalanced data.

  • Multiclass: compute precision and recall per class (one-vs-rest from row and column sums), then macro-, micro-, or weighted-average them.

Q10.
Can you give a concrete example of a false positive and a false negative in a spam filter or medical test, and explain which is more costly?

Junior

A false positive (FP) flags something that isn't there; a false negative (FN) misses something that is. Which is costlier depends on the consequences of each mistake. In a spam filter, FPs are usually worse. In a test for a serious, treatable disease, FNs are usually worse.

  • Spam filter (positive = spam):

    • FP: a legitimate email (a job offer, an invoice) goes to the spam folder and is never seen. This can cause real loss.

    • FN: a spam email reaches the inbox. It's a minor annoyance that the user deletes in seconds.

    • So FP is more costly. Tune the threshold for high precision on the spam class, even if some spam slips through.

  • Medical test (positive = has the disease, e.g. cancer screening):

    • FP: a healthy patient is told they may have cancer. This brings anxiety and a follow-up biopsy, but the error is recoverable.

    • FN: a sick patient is told they're healthy. Treatment is delayed, which can be fatal.

    • So FN is more costly. Screening tests favor high recall (sensitivity), and a more specific confirmatory test then filters out the FPs.

  • Cost is context-dependent, not fixed:

    • FP cost rises when the follow-up is invasive or dangerous (e.g. surgery based on a positive result).

    • FN cost rises with how contagious or fatal the condition is, and with how time-sensitive treatment is.

  • Interview point: once you can estimate the costs, choose the decision threshold that minimizes expected cost (cost_FP·FP + cost_FN·FN). Don't just maximize accuracy.

Q11.
How does balanced accuracy correct for class imbalance compared to plain accuracy?

Junior

Balanced accuracy averages recall over classes instead of over samples. Each class counts equally no matter how many examples it has, so a majority-class guesser scores 0.5 (binary) instead of a misleadingly high accuracy.

  • Definition:

    • Binary: BA = (TPR + TNR) / 2 = (TP/(TP+FN) + TN/(TN+FP)) / 2

    • Multiclass: the mean of per-class recall (macro-averaged recall).

  • Why plain accuracy misleads: Accuracy weights classes by their frequency. With 98% negatives, "always negative" scores 0.98 accuracy but BA = (0 + 1)/2 = 0.5.

  • What it effectively does: It equals the accuracy you would get if the test set were reweighted to equal class priors, so it is insensitive to prevalence.

  • Limitations:

    • It ignores precision, so many false positives on a rare class are only lightly penalized.

    • Chance level is 1/K, not 0. balanced_accuracy_score(..., adjusted=True) rescales chance to 0.

Q12.
What are the trade-offs between MAE, MSE, and RMSE, particularly in the presence of heavy outliers?

Junior

MAE penalizes errors linearly, so it is robust to outliers. MSE squares errors, so a few large misses dominate. RMSE is the square root of MSE: it is in the target's units but has the same outlier sensitivity. With heavy outliers, the right choice depends on whether large errors are noise to ignore or real costs to avoid.

  • MAE:

    • It is in the same units as the target and easy to explain.

    • It is robust: one huge error contributes in proportion to its size, not quadratically.

    • Its optimal constant prediction is the median.

    • It is non-differentiable at 0 and has a constant gradient, which makes optimization a bit less smooth.

  • MSE:

    • It heavily punishes large errors, and its optimal constant prediction is the mean.

    • It is smooth and convex, with gradients proportional to the error, so it's convenient for training.

    • Its units are squared, so it's hard to interpret directly.

    • A few outliers can dominate both the metric and the fitted model.

  • RMSE:

    • It ranks models the same way as MSE but reports in the target's units.

    • RMSE ≥ MAE always holds, and a large gap between them signals high error variance or outliers.

  • Example: errors [1, 1, 1, 1, 20]:

    • MAE = 4.8.

    • RMSE ≈ 9.0, because the single outlier nearly doubles the reported error.

  • Choosing under heavy outliers:

    • If outliers are measurement noise or rare irrelevant events, use MAE (or Huber loss for training).

    • If big misses are disproportionately costly (e.g. a capacity shortfall), use MSE or RMSE deliberately.

    • Report both: the RMSE/MAE gap is itself diagnostic.

Q13.
What does an AUC of 0.5 versus 1.0 indicate on a ROC curve?

Junior

An AUC of 0.5 means the model ranks no better than random guessing. An AUC of 1.0 means perfect separation: every positive is scored above every negative, so some threshold yields TPR = 1 with FPR = 0.

  • Probabilistic interpretation:

    • AUC = probability that a randomly chosen positive gets a higher score than a randomly chosen negative.

    • 0.5 is a coin flip. 1.0 means this always holds.

  • AUC = 0.5:

    • The curve hugs the diagonal and the scores carry no ranking information.

    • A constant predictor also gives 0.5.

  • AUC = 1.0:

    • The curve goes straight up to (0,1), then across.

    • On real held-out data this is a red flag for target leakage or a train/test overlap.

  • Below 0.5: the model ranks systematically backwards (often a flipped label or sign). Inverting the scores gives 1 − AUC.

  • Caveat: AUC measures ranking only. It says nothing about calibration or performance at your chosen threshold.

Q14.
What is the conceptual difference between accuracy and ROC-AUC?

Junior

Accuracy measures the fraction of correct hard labels at one chosen threshold, so it depends on that threshold and on class balance. ROC-AUC measures how well the model ranks positives above negatives across all thresholds, so it evaluates the scores themselves, independent of any cutoff or prevalence.

  • Accuracy:

    • (TP + TN) / total, computed after thresholding (e.g. at 0.5).

    • It is dominated by the majority class: with 99% negatives, predicting all-negative scores 99%.

    • It reflects a deployed decision rule and treats all errors as equally costly.

  • ROC-AUC:

    • Threshold-free: it summarizes the TPR/FPR trade-off over every cutoff.

    • Equals P(score of a random positive > score of a random negative). It is invariant to prevalence and to monotonic score transformations.

    • The all-negative predictor gets 0.5, exposing it as useless.

  • They can disagree:

    • A model can rank perfectly (AUC 1.0) yet have poor accuracy if its threshold is badly placed or its scores are miscalibrated.

    • Conversely, high accuracy can hide poor ranking on imbalanced data.

  • When to use which: use AUC to compare models' discriminative power; use accuracy (or cost-weighted metrics) to judge a specific operating threshold on reasonably balanced data.

Q15.
When is top-k accuracy a more appropriate evaluation criterion than top-1 accuracy?

Junior

Top-k accuracy (true label is among the k highest-scored classes) fits when the system's output is a short list rather than a single committed decision, or when the label space is so ambiguous that the "second-best" guess is often equally correct.

  • The product shows several candidates: Autocomplete, tag suggestions, search suggestions: success means the right answer appears in the list.

  • Multi-stage pipelines: A candidate generator only needs the right item in its top-k; a downstream reranker or rule makes the final call.

  • Human in the loop: E.g. suggesting likely diagnoses or ticket categories for an expert to pick from.

  • Ambiguous or noisy labels, many classes: ImageNet-style fine-grained classes, images with multiple objects, or label noise make top-1 overly harsh (hence ImageNet's top-5).

  • When top-1 is the right choice: The prediction triggers an automatic action (routing, blocking, auto-labeling) with no second chance.

  • Caveats: Top-k ignores order within the k and trivially reaches 1 as k approaches the number of classes; choose k to match the real UI or pipeline, and report top-1 alongside it.

Q16.
Why does log loss punish confident wrong predictions so heavily?

Junior

Log loss charges -log(p), where p is the probability assigned to the true outcome. As p approaches 0 the penalty grows without bound, so a single confident wrong prediction can outweigh many correct ones.

  • The numbers:

    • Probabilities on the true class of 0.9, 0.5, 0.1, 0.01 and 1e-6 cost 0.105, 0.69, 2.3, 4.6 and 13.8 nats respectively.

    • One prediction at 1e-6 on the true class costs about as much as 130 predictions at 0.9.

  • Where the logarithm comes from:

    • Likelihood: the probability of the whole dataset is the product of per-sample probabilities. Taking the log turns it into a sum, and one near-zero factor collapses the product.

    • Information theory: -log p is the "surprise" of the outcome. Saying "impossible" about something that happens means infinite surprise.

    • The gradient with respect to p is -1/p, so training pushes very hard to fix confident mistakes.

  • Why this is desirable:

    • It makes log loss strictly proper and forces honest uncertainty: never claim near-certainty unless you really are that sure.

    • It matters when downstream decisions rely on small probabilities, as in risk, fraud or medicine.

  • Practical caveats:

    • Label noise or a few mislabeled examples can dominate the metric.

    • Implementations clip probabilities (e.g. to [1e-15, 1−1e-15]) to avoid infinite values.

Q17.
Why can aggregate metrics hide critical failures that slicing or subgroup analysis would reveal?

Mid

An aggregate metric is a weighted average over all examples, so it is dominated by the largest, easiest segments. A model can be excellent on the majority while failing badly on a small but important subgroup, and the average barely moves.

  • Averaging dilutes small slices:

    • If a segment is 2% of data, even 0% accuracy on it costs at most 2 points overall.

    • Rare slices are often the high-stakes ones: fraud, new users, minority demographics, rare languages, edge-case inputs.

  • Errors can cancel or shift:

    • A new model can improve overall while regressing on a specific slice; aggregate comparison shows only the net.

    • Simpson's paradox: a model can look better in aggregate yet worse in every subgroup when slice proportions differ.

  • Why it matters:

    • Fairness and compliance risk (disparate error rates across groups).

    • Product risk: a failing segment may be a key market or future growth area.

  • How to do slicing well:

    • Slice by meaningful dimensions (demographics, region, device, input length, label class, data source) and report per-slice metrics with sample sizes and confidence intervals.

    • Set per-slice guardrails so launches require no significant regressions on critical slices.

Q18.
What does setting beta to 0.5 versus 2 in the F-beta score represent?

Mid

Beta sets how much more you care about recall than precision. With β = 0.5 precision is weighted more (false positives hurt more); with β = 2 recall is weighted more (false negatives hurt more).

  • The formula:

    • F_β = (1 + β²) · P · R / (β² · P + R)

    • Recall is treated as β times as important as precision. β = 1 gives the ordinary F1 (harmonic mean).

  • β = 0.5 (precision-leaning): Use when acting on a false alarm is costly: spam filtering (losing a real email), auto-blocking transactions, recommending content you can't retract.

  • β = 2 (recall-leaning): Use when missing a positive is costly: cancer screening, fraud triage before human review, safety defects.

  • Still a harmonic-style mean: A very low value on either component still drags the score down. Beta tilts the trade-off; it doesn't let you ignore one side.

  • Interview tip: pick β from the real cost ratio of FN vs FP, and remember it is threshold-dependent. Tune the decision threshold to maximize the chosen F_β.

python
from sklearn.metrics import fbeta_score fbeta_score(y_true, y_pred, beta=0.5) # favors precision fbeta_score(y_true, y_pred, beta=2) # favors recall

Q19.
Explain the intuition behind the F1 score. Why do we take the harmonic mean rather than the arithmetic or geometric mean of precision and recall?

Mid

F1 is a single score that is high only when both precision and recall are high. The harmonic mean is pulled toward the smaller value, so a model cannot hide terrible recall behind great precision (or vice versa), which the arithmetic mean allows.

  • Definition: F1 = 2PR / (P + R) = 2TP / (2TP + FP + FN)

  • Worked example: P = 1.0, R = 0.01 (predict one sure positive):

    • Arithmetic mean ≈ 0.505: looks mediocre-to-fine despite a useless model.

    • Geometric mean = 0.10: penalizes, but less harshly.

    • Harmonic mean ≈ 0.02: correctly signals failure.

    • In general harmonic ≤ geometric ≤ arithmetic, with equality only when P = R.

  • Why harmonic is the natural choice:

    • Precision and recall are rates sharing the same numerator (TP) with different denominators; the harmonic mean is the correct way to average such ratios.

    • The count form shows F1 compares TP against the average of FP and FN errors, so both error types matter equally.

    • Degenerate models (all-positive or all-negative) get low scores.

  • Limitations:

    • Ignores true negatives and depends on which class is labeled positive.

    • Assumes FP and FN cost the same; use F-beta otherwise.

Q20.
If you double the positive instances in your test set by duplicating them, how do precision, recall, and accuracy change?

Mid

Duplicating positives doubles TP and FN while FP and TN stay fixed. Recall is unchanged, precision goes up, and accuracy shifts toward the model's accuracy on positives (up if recall exceeds the current accuracy, down otherwise).

  • Recall: unchanged: 2TP / (2TP + 2FN) = TP / (TP + FN); it only looks at positives, so the ratio is preserved.

  • Precision: increases (unless FP = 0): 2TP / (2TP + FP); TP grows but FP doesn't. Precision depends on class prevalence.

  • Accuracy: moves toward recall:

    • (2TP + TN) / (2P + N) is a prevalence-weighted mix of recall and specificity; more positives shift weight to recall.

    • Example: TP=40, FN=10, FP=20, TN=930: accuracy 97% → 96.2%, precision 0.667 → 0.80, recall 0.80 stays.

  • Takeaways:

    • Recall, specificity, FPR and ROC-AUC are prevalence-invariant; precision, accuracy, F1 and PR-AUC are not.

    • Never rebalance a test set this way: it should reflect production prevalence, or reported precision will be inflated.

Q21.
Why is the Matthews correlation coefficient considered more informative than accuracy or F1 on imbalanced binary classification?

Mid

MCC is a correlation between predictions and labels that uses all four confusion-matrix cells symmetrically. It is high only when the model does well on both classes, so it can't be inflated by the majority class (as accuracy can) or by ignoring true negatives (as F1 does).

  • Definition:

    • MCC = (TP·TN − FP·FN) / sqrt((TP+FP)(TP+FN)(TN+FP)(TN+FN))

    • Range −1 to +1: +1 is perfect, 0 is no better than random, −1 is total disagreement.

  • Why accuracy fails: It is dominated by the majority class. Predicting all negatives on 99:1 data gives 99% accuracy but MCC = 0.

  • Why F1 fails:

    • It ignores TN entirely and depends on which class you call positive.

    • Example: 95 positives and 5 negatives, model predicts all positive. F1 ≈ 0.97 and accuracy = 0.95, yet MCC = 0 (by convention, since a denominator term is zero).

  • Why MCC is robust:

    • It is invariant to swapping which class is positive.

    • A high score requires good precision and recall for both classes at once.

  • Caveats:

    • It is threshold-dependent, like F1.

    • It is less intuitive to explain to stakeholders.

    • If you only care about the positive class (e.g., retrieval), F1 or PR-AUC may still match the business goal better.

python
from sklearn.metrics import matthews_corrcoef matthews_corrcoef(y_true, y_pred)

Q22.
What does Cohen's kappa correct for that plain accuracy does not?

Mid

Cohen's kappa corrects for agreement expected by chance given each side's label frequencies. Accuracy counts all agreement as skill, even agreement a random guesser with the same class proportions would reach.

  • Definition:

    • κ = (p_o − p_e) / (1 − p_e)

    • p_o is the observed agreement (that is, accuracy).

    • p_e is the chance agreement: sum over classes of (predicted-class rate × true-class rate).

  • Interpretation:

    • 1 is perfect, 0 is chance-level, and negative is worse than chance.

    • Kappa is the fraction of the possible above-chance agreement that was actually achieved.

  • Example: 90% majority class, model always predicts majority: p_o = 0.9 and p_e = 0.9·1 + 0.1·0 = 0.9, so κ = 0, despite 90% accuracy.

  • Caveats:

    • Kappa depends on prevalence (the "kappa paradox"): high accuracy can yield low κ when classes are very skewed, so it is hard to compare across datasets.

    • Use weighted kappa (linear or quadratic) for ordinal labels, so near-misses are penalized less.

    • It was originally an inter-rater agreement measure; for classifiers, MCC is often preferred.

Q23.
Why is the precision of a classifier dependent on the class prevalence in the test set while recall and specificity are not?

Mid

Recall and specificity are each conditioned on a single true class, so changing how many positives versus negatives you have doesn't change them. Precision is conditioned on the predicted-positive set, which mixes true positives from the positive class with false positives from the negative class. Their ratio therefore shifts with prevalence.

  • Single-class rates are invariant:

    • Recall = TP / (TP + FN) = P(ŷ=1 | y=1). It uses only actual positives.

    • Specificity = TN / (TN + FP) = P(ŷ=0 | y=0). It uses only actual negatives.

    • Doubling the negatives doubles TN and FP together, so specificity stays the same.

  • Precision mixes classes (Bayes' rule):

    • Precision = TPR·π / (TPR·π + FPR·(1 − π)), where π is prevalence.

    • The model's TPR and FPR are fixed, but π scales how many FPs show up relative to TPs.

  • Worked example (TPR = 0.9, FPR = 0.05):

    • π = 50%: precision ≈ 0.95.

    • π = 1%: precision ≈ 0.009 / (0.009 + 0.0495) ≈ 0.15. The model is the same, but precision is far worse.

  • Practical implications:

    • A test set that is balanced (or downsampled) overstates the precision you'll see in production when positives are rare.

    • Precision, PR curves and F1 aren't comparable across datasets with different prevalence. ROC/AUC is prevalence-invariant.

    • Fix: evaluate at the deployment prevalence, or recompute precision from TPR, FPR and the expected π.

Q24.
What are the pitfalls of MAPE as a regression metric?

Mid

MAPE is intuitive ("off by 8% on average"), but it breaks near zero, penalizes over- and under-prediction asymmetrically, and lets small-valued points dominate. Optimizing it pushes models toward biased, low forecasts.

  • Definition: MAPE = mean(|y − ŷ| / |y|)

  • Zero and near-zero actuals:

    • It is undefined when y = 0 and explodes when y is tiny.

    • This is common in intermittent demand, sales of slow movers, and counts.

  • Asymmetric penalty:

    • For non-negative forecasts, under-prediction error is capped at 100%, while over-prediction error is unbounded.

    • The model is therefore rewarded for under-forecasting. The MAPE-optimal point forecast sits below the median.

  • Scale distortion:

    • An error of 5 on an actual of 10 counts 50%, while an error of 500 on an actual of 10,000 counts only 5%.

    • Low-volume items dominate the average, even though they usually matter least to the business.

  • Needs a meaningful zero: Percentages make no sense on interval scales (e.g., temperature in °C).

  • Alternatives:

    • WAPE (sum |error| / sum |actual|): volume-weighted and robust to small values.

    • MASE: scaled against a naive forecast, so it is comparable across series.

    • MAE or RMSE, when percentages aren't required.

    • sMAPE patches some issues but has its own instability and asymmetry.

Q25.
How does quantile (pinball) loss let you evaluate asymmetric business costs in regression?

Mid

Pinball loss penalizes under- and over-prediction with different slopes (τ and 1−τ). Its minimizer is the τ-th quantile, so choosing τ from the ratio of business costs makes the loss track the expected cost of your forecast errors.

  • Definition, for residual u = y − q:

    • L_τ = τ·u if u ≥ 0 (under-prediction).

    • L_τ = (1 − τ)·(−u) if u < 0 (over-prediction).

    • τ = 0.5 reduces to half the MAE, which targets the median.

  • Mapping costs to τ (newsvendor logic):

    • If a unit of under-prediction costs C_u (stockout) and a unit of over-prediction costs C_o (excess inventory), set τ = C_u / (C_u + C_o).

    • Example: a stockout is 3× worse than overstock, so τ = 0.75. The optimal forecast is the 75th percentile.

    • Pinball loss at that τ is proportional to the linear asymmetric cost, so comparing models on it means comparing expected business cost.

  • Evaluating quantile forecasts:

    • Score each predicted quantile with its own τ. Averaging across many τ approximates CRPS for a full predictive distribution.

    • Also check calibration: about τ of the actuals should fall below the τ-quantile forecast.

  • Contrast with MSE and MAE: both are symmetric and target the mean or median, which is the wrong point when the costs are lopsided.

python
from sklearn.metrics import mean_pinball_loss # stockout 3x costlier than overstock -> tau = 0.75 mean_pinball_loss(y_true, y_pred_q75, alpha=0.75)

Q26.
When a model optimizes MAE versus MSE, what statistical property of the conditional distribution is it predicting?

Mid

Minimizing MSE makes the model predict the conditional mean E[Y | X]. Minimizing MAE makes it predict the conditional median. For skewed or heavy-tailed targets these differ, so the choice of loss decides what your prediction actually means.

  • Why (minimize over a constant c for a fixed X):

    • MSE: d/dc E[(Y − c)²] = −2(E[Y] − c) = 0, so c = E[Y]. That is the mean.

    • MAE: d/dc E|Y − c| = P(Y < c) − P(Y > c) = 0, so half the mass lies on each side. That is the median.

  • When it matters:

    • Symmetric noise (e.g. Gaussian): the mean equals the median, so both losses target the same value.

    • Right-skewed targets (income, sales, latency): the mean exceeds the median. An MAE model systematically under-predicts totals.

    • So use MSE when you need sums or aggregates to be unbiased, and MAE for a robust "typical" value.

  • Common trap: log-transformed targets:

    • Training with MSE on log(Y) predicts E[log Y | X].

    • Exponentiating that gives roughly the median (geometric mean), not the mean of Y. You need a bias correction if you want the mean.

  • The general pattern:

    • Pinball loss at τ gives the τ-quantile.

    • 0-1 loss gives the mode.

    • Pick the loss whose minimizer matches the decision you need, and evaluate with the same functional.

Q27.
Why is Huber loss useful when evaluating predictions on data with heavy outliers?

Mid

Huber loss is quadratic for small errors and linear for large ones. Typical errors are judged as precisely as with MSE, but a few extreme outliers can't dominate the score the way their squared errors would.

  • Definition, for residual r and threshold δ:

    • 0.5·r² if |r| ≤ δ.

    • δ·(|r| − 0.5·δ) otherwise.

  • Why it helps with outliers:

    • With MSE, one residual of 100 contributes 10,000 and swamps the aggregate.

    • With Huber, the contribution grows only linearly, and each point's gradient (influence) is capped at δ.

  • Why not just MAE:

    • Huber keeps MSE's smoothness and efficiency near zero.

    • It is differentiable everywhere, so it is also a stable training loss.

    • It still distinguishes small errors finely.

  • Choosing δ:

    • δ sets where "normal noise" ends. Base it on the residual scale (e.g., 1.345·σ gives about 95% of MSE's efficiency under Gaussian noise).

    • δ → ∞ recovers MSE; δ → 0 approaches a scaled MAE.

  • Caveat: if the outliers are the expensive events you must predict (e.g., demand spikes), down-weighting them hides real failures. Report a tail metric alongside.

Q28.
Why are scale-free regression metrics like MASE useful?

Mid

Scale-free metrics like MASE (Mean Absolute Scaled Error) express error relative to a simple benchmark rather than in raw units. That lets you compare and average accuracy across series with different magnitudes or units, and tells you directly whether a model beats a naive forecast.

  • How MASE is defined:

    • MASE = MAE of the model ÷ in-sample MAE of a naive forecast (previous value, or the value one season ago for seasonal data).

    • MASE < 1 means the model beats the naive baseline; MASE > 1 means it is worse than just repeating the last value.

  • Why scale-freeness matters:

    • MAE or RMSE on a series in millions dwarfs one in units, so averaging raw errors across many SKUs or stores is meaningless.

    • A scaled error is unitless, so it can be aggregated and compared across series and datasets.

  • Advantages over percentage errors (MAPE):

    • MAPE is undefined or explodes when actuals are zero or near zero (intermittent demand). MASE stays finite unless the whole training series is constant.

    • MAPE is asymmetric and penalizes over- and under-forecasts differently. MASE treats both symmetrically.

  • Caveat: the scaling depends on the chosen naive benchmark and the in-sample period, so report which one you used.

python
import numpy as np def mase(y_train, y_true, y_pred, m=1): # m = seasonal period scale = np.mean(np.abs(y_train[m:] - y_train[:-m])) # naive in-sample MAE return np.mean(np.abs(y_true - y_pred)) / scale

Q29.
What is the probabilistic interpretation of ROC-AUC?

Mid

ROC-AUC equals the probability that the model scores a randomly chosen positive higher than a randomly chosen negative, with ties counted as half. It is therefore a measure of ranking quality, not of calibrated probabilities.

  • Formal statement:

    • AUC = P(s(x⁺) > s(x⁻)) + 0.5 · P(s(x⁺) = s(x⁻)).

    • Equivalently, it is the fraction of all positive–negative pairs that are correctly ordered.

  • Connection to statistics:

    • It is the Mann–Whitney U statistic divided by n⁺ · n⁻.

    • The Gini coefficient used in credit scoring is 2·AUC − 1.

  • Consequences:

    • It is invariant to any monotone transform of scores, so it says nothing about calibration.

    • It is threshold-free. 0.5 means random ordering, 1.0 means every positive outranks every negative.

    • Every pair counts equally, including easy negatives far down the ranking. This is why it can look good while the top of the list is poor.

python
import numpy as np pos, neg = scores[y == 1], scores[y == 0] diff = pos[:, None] - neg[None, :] auc = np.mean(diff > 0) + 0.5 * np.mean(diff == 0) # matches roc_auc_score

Q30.
Why does ROC-AUC remain overly optimistic on datasets with extreme class imbalance?

Mid

ROC-AUC uses the false positive rate, whose denominator is the total number of negatives. When negatives vastly outnumber positives, even a large absolute number of false positives produces a tiny FPR. The curve and AUC therefore look excellent while precision, the thing that matters operationally, can be terrible.

  • The arithmetic:

    • FPR = FP / (FP + TN). With 1,000,000 negatives, 10,000 false positives is only a 1% FPR.

    • With 1,000 positives and 900 caught, precision = 900 / (900 + 10,000) ≈ 8%. ROC looks great, but most alerts are wrong.

  • AUC averages over all thresholds:

    • It rewards correctly ranking the easy majority of negatives (the long tail of obvious negatives), which inflates the score.

    • In practice you only operate in the low-FPR, top-ranked region, which is a small slice of the curve.

  • Prevalence-invariance cuts both ways: AUC is stable across class ratios, which also means it is blind to the cost of false positives when positives are rare.

  • Better choices under extreme imbalance:

    • PR-AUC / average precision: its baseline equals prevalence and it degrades visibly as FPs pile up.

    • Precision@k, recall at fixed precision, or partial AUC restricted to low FPR.

Q31.
What does the baseline value of a ROC curve versus a precision-recall curve represent?

Mid

Both baselines show the performance of a random (no-skill) classifier. On a ROC curve that is the diagonal TPR = FPR, giving AUC 0.5 regardless of class balance. On a precision-recall curve it is a horizontal line at precision = positive-class prevalence, so the baseline moves with the dataset.

  • ROC baseline:

    • Random scoring flags positives and negatives at the same rate, so TPR = FPR at every threshold.

    • The AUC baseline is always 0.5, independent of prevalence. That makes ROC-AUC comparable across datasets.

  • PR baseline:

    • A random classifier's precision equals the fraction of positives, P / (P + N), at any recall.

    • Expected average precision of a random model ≈ prevalence. That is 0.5 for balanced data but 0.01 for 1% positives.

  • Practical implication:

    • Always read PR-AUC relative to prevalence: 0.30 is strong if prevalence is 0.01, weak if it is 0.25.

    • PR-AUC is not directly comparable across datasets with different class ratios. ROC-AUC is.

Q32.
How are lift and cumulative gain charts used to evaluate a model for targeting campaigns?

Mid

Both charts rank the population by model score and ask how many responders you capture by targeting the top x%. A cumulative gain chart shows the share of all positives captured. A lift chart shows how many times better that is than random targeting. Together they help you pick how deep to go given a campaign budget.

  • Construction:

    1. Score the holdout set and sort it descending.

    2. Split it into bins (usually deciles).

    3. For each depth, compute the cumulative positives captured.

  • Cumulative gain chart:

    • x-axis: % of population targeted. y-axis: % of all positives captured.

    • The random baseline is the diagonal; a perfect model rises at slope 1/prevalence until it reaches 100%.

    • Example reading: "contacting the top 20% reaches 60% of responders."

  • Lift chart:

    • Lift at depth x = (gain at x) / x, i.e. the response rate in the targeted group ÷ the overall response rate.

    • In the example above, top-20% lift = 60/20 = 3×. Lift always converges to 1 at 100% of the population.

  • How they drive decisions:

    • With a fixed budget (e.g. only 10% can be contacted), compare models by gain or lift at that depth rather than by global AUC.

    • Combine with cost per contact and value per response to find the profit-maximizing cutoff, where marginal lift no longer pays for the contact cost.

  • Caveat: these charts measure response propensity, not causal effect. To target people who are persuadable by the campaign, use uplift models evaluated with Qini or uplift curves.

Q33.
Why is the Kolmogorov-Smirnov (KS) statistic popular in credit risk scoring?

Mid

KS is the maximum vertical distance between the cumulative score distributions of good and bad borrowers. It gives credit teams a single, intuitive number for how well a scorecard separates the two groups, plus the score where that separation peaks. It also has decades of regulatory and industry tradition behind it.

  • Definition:

    • KS = max over score s of |F_bad(s) − F_good(s)|, equivalently max(TPR − FPR) on the ROC curve (Youden's J).

    • It ranges from 0 (no separation) to 1 (perfect). It is often reported in % (e.g. 40–60 is typical for good retail scorecards).

  • Why practitioners like it:

    • Easy to explain to business and risk committees: "at score 620, we have captured 55% more of the bads than of the goods."

    • It points to a natural candidate cutoff, which suits the accept/reject decision framing.

    • It is non-parametric and rank-based, so it is robust to score scaling and fits the decile and score-band reports already used in credit.

    • It is an entrenched standard for model validation and monitoring, so KS drift over time is a common stability check.

  • Limitations:

    • It reflects separation at only one point. Two models with equal KS can differ elsewhere, so pair it with Gini (= 2·AUC − 1).

    • The peak may fall at a score that is not operationally relevant.

    • It ignores calibration, so PD accuracy still needs separate checks (e.g. binomial tests, calibration plots).

Q34.
What is the difference between MRR, MAP, and NDCG as ranking metrics?

Mid

All three reward putting relevant items near the top. MRR cares only about the first relevant item. MAP averages precision over every relevant item with binary relevance. NDCG supports graded relevance with a logarithmic position discount.

  • MRR (Mean Reciprocal Rank):

    • Per query: 1 / rank of the first relevant item. Average this over queries.

    • Fits single-answer tasks: QA, navigational search, "did the right item show up first."

    • It ignores everything after the first hit.

  • MAP (Mean Average Precision):

    • AP per query = mean of precision@k at each rank k holding a relevant item, divided over the total number of relevant items. MAP is the mean of AP over queries.

    • Rewards retrieving all relevant items early.

    • Binary relevance only.

  • NDCG (Normalized Discounted Cumulative Gain):

    • DCG@k = Σ (2rel − 1) / log2(i + 1). NDCG = DCG / ideal DCG, giving a value in [0, 1].

    • Handles graded labels (e.g. perfect, good, fair). Common in web search and recommendations, usually reported with a cutoff such as @10.

  • Choosing: use MRR for one right answer, MAP for many equally relevant items, and NDCG for graded relevance or top-k display.

Q35.
Why do we normalize DCG by the ideal DCG?

Mid

Raw DCG has no fixed scale: its value depends on how many relevant items a query has and their grades. Dividing by the ideal DCG (the DCG of the perfect ordering) maps each query to [0, 1], so scores are comparable across queries and can be averaged fairly.

  • DCG recap: DCG@k = Σ gain(rel_i) / log2(i + 1), with gain often 2^rel - 1 or rel.

  • Problem without normalization:

    • A query with 20 highly relevant docs gets a large DCG even with a mediocre ranking; a query with 1 relevant doc caps out low even if ranked perfectly.

    • Averaging raw DCG lets "rich" queries dominate and measures query difficulty, not ranking quality.

  • What IDCG does:

    • IDCG@k: sort items by true relevance, compute DCG@k. It is the best achievable score for that query.

    • NDCG = DCG / IDCG reads as "fraction of the best possible ranking achieved"; 1.0 means perfect order.

  • Edge cases:

    • Queries with no relevant items have IDCG = 0: define NDCG as 0 or exclude them, and state which.

    • IDCG should use all judged relevant items, not just those the model retrieved, or the metric is inflated.

Q36.
Beyond relevance metrics like NDCG, how do you measure the quality of a recommendation slate using hit rate, coverage, and diversity?

Mid

Relevance metrics check whether the right items are ranked highly. Slate quality also depends on whether users get any useful hit at all (hit rate), how much of the catalog the system actually exposes (coverage), and how varied each slate is (diversity). Optimizing accuracy alone tends to collapse onto popular, near-duplicate items.

  • Hit rate@k:

    • The fraction of users whose top-k list contains at least one held-out item they actually interacted with. It is typically evaluated with leave-one-out splits.

    • Simple and interpretable, but it ignores position within the slate and stops counting after the first hit.

  • Coverage:

    • Catalog coverage: the number of unique items recommended across all users divided by catalog size.

    • User coverage: the share of users who can receive meaningful recommendations, which matters for cold-start users.

    • Exposure concentration: the Gini coefficient or entropy of item impressions, which detects popularity bias that coverage alone misses.

  • Diversity:

    • Intra-list diversity: the average pairwise dissimilarity within a slate, e.g. 1 − cosine similarity of item embeddings, or differing categories.

    • Aggregate (cross-user) diversity: how different slates are across users, which guards against everyone seeing the same list.

    • Related measures: novelty (inverse popularity) and serendipity (relevant and unexpected).

  • Using them together:

    • Expect a trade-off. Diversity re-ranking (e.g. MMR) often costs a little NDCG, so report the full set of metrics and choose an operating point deliberately.

    • Offline proxies are imperfect. Validate with online A/B metrics such as engagement, retention and long-term satisfaction.

Q37.
Why is precision@k not monotonic as k increases?

Mid

Precision@k is a ratio (relevant items in top k) / k. Moving from k to k+1 adds 1 to the denominator but adds to the numerator only if item k+1 is relevant, so the value rises or falls depending on what sits at the next position.

  • Mechanics:

    • Relevant item at k+1: precision goes up (unless it was already 1).

    • Irrelevant item at k+1: precision goes down.

    • Example ranking R, N, R, R: P@1 = 1.0, P@2 = 0.5, P@3 = 0.67, P@4 = 0.75.

  • Contrast with recall@k: Recall@k has a fixed denominator (total relevant), so it is monotonically non-decreasing in k.

  • Practical consequences:

    • Model rankings can flip depending on the k you choose; pick k to match what users actually see.

    • If a query has fewer than k relevant items, the max P@k is below 1, adding a bias across queries (R-precision fixes this by setting k = number of relevant items).

    • The sawtooth shape is why the PR curve is often interpolated and why average precision averages P@k at each relevant position.

Q38.
What is hit rate@k, and in what recommendation use cases is it preferred over rank-aware metrics like NDCG?

Mid

Hit rate@k is the fraction of users (or queries) for which at least one relevant item appears in the top k. It is binary per user and ignores where in the list the hit landed. That makes it a good fit when position inside the list doesn't matter much, or when there is only one held-out target.

  • Computation:

    • Score each user 1 if any relevant item is in the top k, else 0. Then average across users.

    • Common with leave-one-out evaluation: hold out each user's last interaction and check whether it lands in the top k.

    • With a single held-out item, hit rate@k equals recall@k.

  • When it is preferred over NDCG:

    • Next-item prediction where each user has exactly one ground-truth item.

    • Candidate generation or retrieval stages: the question is only whether the item survived into the set, because a downstream ranker will reorder it.

    • Layouts where order barely matters: grids, small carousels, or "you might also like" blocks where all k items are visible at once.

    • Binary implicit feedback with no graded relevance, so NDCG's gain structure adds little.

    • Stakeholder communication: "we surfaced something useful for 62% of users" is easy to explain.

  • Limitations:

    • Rank 1 and rank k count the same.

    • One hit is as good as many hits.

    • It saturates as k grows.

    • For ranked feeds or search with strong position bias, use NDCG or MRR instead.

Q39.
Why is NDCG@k often preferred over precision@k in search and recommendation?

Mid

NDCG@k rewards putting the most relevant items at the very top and supports graded relevance, while precision@k only counts binary hits in the top k and ignores their order. In search and recommendation, users mostly look at the first few results, so position and degree of relevance matter.

  • Position sensitivity:

    • NDCG discounts gains by 1 / log2(rank + 1), so a relevant item at rank 1 counts more than at rank 10.

    • Precision@k gives the same score whether the relevant items sit at ranks 1-3 or 8-10.

  • Graded relevance:

    • NDCG uses levels (e.g. perfect / good / fair, or purchase > click > view).

    • Precision@k forces a binary threshold and loses that information.

  • Comparable across queries: Normalization by the ideal DCG puts every query on [0, 1]; precision@k's ceiling drops when a query has fewer than k relevant items.

  • When precision@k is still fine: Labels are binary, results are shown as an unordered set (e.g. a grid), or stakeholders need an easily explained number.

  • Caveats of NDCG: Needs graded labels; the gain and discount functions are conventions, and scores are less intuitive to explain.

Q40.
When can micro-averaged, macro-averaged, or weighted F1 be misleading in multi-class classification?

Mid

Each averaging scheme answers a different question, and each hides something: micro and weighted F1 are dominated by large classes, while macro F1 treats every class equally and becomes noisy or overly harsh when some classes are tiny.

  • Micro F1 (pool all TP/FP/FN):

    • In single-label multi-class it equals accuracy, so it inherits accuracy's problems under imbalance.

    • A model that ignores minority classes can still score high.

  • Macro F1 (unweighted mean of per-class F1):

    • A rare class with 5 test samples moves the score as much as a class with 50,000, so it has high variance.

    • Classes never predicted have undefined precision; the zero_division setting can silently change the result.

    • Misleading if business value is concentrated in the big classes.

  • Weighted F1 (per-class F1 weighted by support):

    • Looks "balanced" but is again dominated by majority classes, close to micro F1.

    • Weights come from the test set's distribution, which may differ from production.

    • Can produce an F1 not between the averaged precision and recall, which confuses readers.

  • General pitfalls: Any single average hides which classes fail; F1 also ignores true negatives and error costs between specific classes.

  • What to do:

    • Report per-class precision/recall/F1 and a confusion matrix, with confidence intervals for small classes.

    • Pick the average that matches the goal: macro if every class matters equally, micro/weighted if every example does, or a cost-weighted metric.

Q41.
Under what conditions will micro-averaged precision, micro-averaged recall, and multi-class accuracy be identical?

Mid

The three are identical in single-label multi-class classification, provided two conditions hold: every sample gets exactly one predicted class, and all classes are included in the micro-average. In that setting each error is simultaneously one false positive and one false negative, so total FP equals total FN, and both metrics reduce to correct / total.

  • Why they coincide:

    • A misclassification of a true A as B adds one FP (for B) and one FN (for A).

    • Summed over classes, TP + FP = N (all predictions) and TP + FN = N (all true labels).

    • So micro-precision = TP/N, micro-recall = TP/N, and accuracy = TP/N. Micro-F1 equals them too.

  • When they diverge:

    • Multi-label problems: a sample can have several true or predicted labels, so FP ≠ FN.

    • Abstention or a reject option: some samples get no prediction, so FP < FN.

    • Excluding classes from averaging, e.g. dropping the "O"/negative class in NER via the labels= argument in scikit-learn.

    • Predicting multiple classes per sample (top-k outputs).

  • Interview takeaway: if micro-P, micro-R and accuracy differ in a supposedly single-label setup, check for excluded labels, abstentions or a label-format bug.

Q42.
How do you evaluate a multi-label classification system where an item can belong to zero, one, or several classes simultaneously?

Mid

Treat the problem as one binary decision per label, then score it from three angles: per example (how right is each item's label set), per label (how good is each label's classifier), and by ranking (are true labels scored above false ones). Report a small set from each family, because no single number captures multi-label quality.

  • Example-based metrics (one score per item, then averaged):

    • Subset accuracy (exact match): the predicted set must equal the true set. It is very strict and drops fast as the number of labels grows.

    • Hamming loss: the fraction of individual label slots that are wrong. It is lenient and dominated by easy negatives when labels are sparse.

    • Sample-averaged F1 or Jaccard (average='samples'): gives partial credit for overlap between the predicted and true sets.

  • Label-based metrics (one score per label):

    • Micro-F1 pools all label decisions, so frequent labels dominate.

    • Macro-F1 averages per-label F1 equally, which exposes weak rare labels.

    • Look at per-label precision and recall to find which labels underperform.

  • Ranking and threshold-free metrics:

    • Mean average precision (per-label PR-AUC averaged), label ranking average precision, ranking loss, and coverage.

    • These separate scoring quality from the choice of threshold.

  • Practical details:

    • Items with zero labels: decide the convention up front. If both the true and predicted sets are empty, is that a perfect score or excluded? Libraries handle this differently.

    • Tune a threshold per label (or use top-k / a cardinality model) instead of a global 0.5.

    • Use iterative stratification for splits so rare label combinations appear in every fold.

    • Check label co-occurrence errors, e.g. the model always predicts B whenever A is present.

python
from sklearn.metrics import f1_score, hamming_loss, accuracy_score, average_precision_score # Y_true, Y_pred: (n_samples, n_labels) binary indicator matrices; Y_score: probabilities accuracy_score(Y_true, Y_pred) # subset accuracy hamming_loss(Y_true, Y_pred) f1_score(Y_true, Y_pred, average='samples', zero_division=1) f1_score(Y_true, Y_pred, average='macro') average_precision_score(Y_true, Y_score, average='macro') # mAP

Q43.
How do you extend ROC-AUC to a multi-class problem?

Mid

ROC-AUC is binary, so you decompose the multi-class problem into binary ones (one-vs-rest or one-vs-one), compute AUC for each, and average them; micro-averaging over all class indicators is a third option.

  • One-vs-rest (OvR):

    • For each class c, use the score for c, treat c as positive and all others as negative, compute AUC.

    • Average with macro (equal weight per class) or weighted (by class prevalence).

    • Caveat: the "rest" group's composition depends on class frequencies, so OvR is sensitive to imbalance.

  • One-vs-one (OvO, Hand & Till 2001):

    • Compute AUC for every pair of classes using only samples from those two classes, then average over all pairs.

    • With macro averaging it is insensitive to class imbalance; cost is O(C²) pairs.

  • Micro-average: Binarize labels into an n × C indicator matrix, flatten it with the scores, and compute one AUC; dominated by frequent classes.

  • Interpretation caveat: High multi-class AUC means good per-class ranking, not good argmax accuracy or calibration; check per-class AUCs too.

python
from sklearn.metrics import roc_auc_score # proba: (n_samples, n_classes), rows sum to 1 roc_auc_score(y, proba, multi_class="ovr", average="macro") roc_auc_score(y, proba, multi_class="ovo", average="macro")

Q44.
How do you use a multi-class confusion matrix to perform per-class error analysis and identify which classes the model systematically confuses?

Mid

Normalize the confusion matrix so prevalence doesn't hide errors, then look at the largest off-diagonal cells: they show exactly which true class is being predicted as which wrong class. Next, inspect real examples from those cells to find out why, and turn the findings into targeted fixes.

  • Read and normalize correctly:

    • Rows are true classes and columns are predictions.

    • Row-normalize (normalize='true') to see where each class's examples go. The diagonal is per-class recall.

    • Column-normalize to see what each prediction actually contains. The diagonal is per-class precision.

    • Keep the raw counts nearby: a 40% confusion based on 5 samples is just noise.

  • Find the systematic confusions:

    1. Zero out the diagonal and rank the off-diagonal cells by rate and by count (the impact).

    2. Symmetric pairs (A→B and B→A) point to similar or ambiguous classes, overlapping definitions, or label noise.

    3. Asymmetric patterns, such as one column absorbing many classes, point to a "sink" class. This often comes from majority-class bias or an "other" bucket.

    4. Reorder or cluster the rows and columns (for example by hierarchy) so blocks of confusable classes stand out.

  • Diagnose with examples:

    • Pull samples from the top cells, especially high-confidence errors.

    • Sort each one into a cause: mislabeled data, a genuinely ambiguous taxonomy, missing signal or features, or too little training data for that class.

  • Act on the findings:

    • Relabel the data or clarify labeling guidelines.

    • Merge classes that are truly indistinguishable, or use a hierarchical model.

    • Collect targeted data, use class weights, or adjust per-class thresholds.

    • Track the key confusion pairs across model versions to check that a fix doesn't simply move the errors elsewhere.

Q45.
Given a model that outputs probabilities, how do you choose the decision threshold instead of defaulting to 0.5?

Mid

The threshold is a business decision, not a property of the model. Pick it on a validation set by sweeping candidate thresholds and choosing the one that best meets your objective: minimum expected cost, a target recall or precision, a capacity limit, or a metric like F-beta. 0.5 is only optimal when probabilities are calibrated and false positives and false negatives cost the same.

  • Common selection criteria:

    • Cost-based: with calibrated probabilities and zero cost for correct predictions, predict positive when p > C_FP / (C_FP + C_FN).

    • Constraint-based: the highest-precision threshold that keeps recall ≥ target, or that keeps alert volume ≤ capacity.

    • Metric-based: maximize F1 or F-beta (beta > 1 weights recall more), or Youden's J on the ROC curve.

  • Procedure:

    1. Score a held-out validation set that reflects production prevalence. Never tune on the test set.

    2. Sweep thresholds with precision_recall_curve or roc_curve and compute the objective at each one.

    3. Choose the best threshold, then report final metrics on the untouched test set.

  • Pitfalls:

    • Uncalibrated scores make cost formulas meaningless, so calibrate first (Platt scaling, isotonic regression).

    • Resampling or class weights during training shift the score distribution, so re-tune the threshold afterwards.

    • Thresholds are noisy when there are few positives: check stability with bootstrapping, and re-tune when prevalence or score drift appears.

python
import numpy as np from sklearn.metrics import precision_recall_curve p, r, t = precision_recall_curve(y_val, scores_val) f1 = 2 * p[:-1] * r[:-1] / (p[:-1] + r[:-1] + 1e-12) best_t = t[np.argmax(f1)] # F1-optimal threshold on validation # cost-based alternative (calibrated probs): best_t = C_FP / (C_FP + C_FN)

Q46.
How do you evaluate a model using a cost matrix instead of standard thresholded classification metrics?

Mid

Assign a cost (or benefit) to every cell of the confusion matrix, then judge the model by the total or average cost of its decisions instead of accuracy or F1. With calibrated probabilities you also make decisions that minimize expected cost, so the cost matrix drives both the decision rule and the evaluation.

  • Define the cost matrix:

    • C[i][j] is the cost of predicting class j when the truth is i. For example, a missed fraud might cost $500 while an unnecessary review costs $5.

    • Get the costs from the business (losses, analyst time, customer churn). Costs can also vary per example, such as the transaction amount.

  • Cost-optimal decisions:

    • For each example, predict argmin over j of Σ_i p(i|x) · C[i][j], the action with the lowest expected cost.

    • In the binary case with zero cost for correct predictions, this reduces to a threshold t = C_FP / (C_FP + C_FN).

    • This only works if the probabilities are calibrated.

  • Evaluate:

    • Total cost = Σ (confusion counts × costs). Report it per example or per day so it can be compared.

    • Compare against baselines: predict-all-negative, flag-everything, and the current production system. Savings relative to these baselines is the number stakeholders care about.

    • Add bootstrap confidence intervals, because a few expensive errors can dominate the total.

  • When costs are uncertain:

    • Run a sensitivity analysis: sweep the cost ratio and check whether the model ranking or the chosen threshold changes.

    • Cost curves (Drummond & Holte) plot expected cost across all operating conditions, a more decision-oriented view than ROC.

python
import numpy as np # proba: (n, K) calibrated; C: (K, K), C[i, j] = cost of predicting j when truth is i expected_cost = proba @ C # (n, K): expected cost of each action pred = expected_cost.argmin(axis=1) avg_cost = C[y_true, pred].mean() # realized cost on the test set

Q47.
How do you use Youden's J statistic to pick an operating threshold from a ROC curve?

Mid

Youden's J = TPR − FPR (sensitivity + specificity − 1). For each threshold on the ROC curve you compute J and pick the threshold that maximizes it: the point farthest vertically above the random-guess diagonal.

  • Procedure:

    1. Compute the ROC curve on a validation set (not the test set) to get FPR, TPR, and thresholds.

    2. Compute J = TPR − FPR at each threshold.

    3. Choose the threshold with the largest J; evaluate it once on the test set.

  • Interpretation:

    • J ranges from 0 (no better than chance) to 1 (perfect separation).

    • It maximizes balanced accuracy, i.e. weights sensitivity and specificity equally.

  • Hidden assumptions:

    • Treats a false negative and a false positive as equally costly and ignores prevalence.

    • With rare positives or asymmetric costs (missed cancer vs extra biopsy), pick the threshold minimizing expected cost, or use a constraint like "max TPR at FPR ≤ 1%".

  • Practical notes:

    • The optimum can be noisy on small data; bootstrap it or smooth the curve.

    • Re-tune if class balance or score distributions shift in production.

python
import numpy as np from sklearn.metrics import roc_curve fpr, tpr, thr = roc_curve(y_val, scores_val) best = np.argmax(tpr - fpr) threshold = thr[best]

Q48.
How would you choose a threshold to meet a business constraint such as a minimum recall of 95% or a fixed review capacity of 1,000 alerts per day?

Mid

Turn each constraint into a rule over the score distribution. For a recall floor, choose the highest threshold on validation data that still achieves recall ≥ 95%, which maximizes precision subject to that floor. For a capacity limit, choose the score cutoff (or top-k) that produces about 1,000 alerts per day on production-like traffic. In both cases, build in margin for sampling noise and drift.

  • Minimum recall of 95%:

    • Sweep thresholds on a representative validation set and keep those with recall ≥ 0.95. Pick the largest, since it gives the best precision.

    • Recall estimated from few positives is noisy, so use a bootstrap or binomial lower bound and pick a threshold whose lower confidence bound still clears 95%.

    • Report the precision and alert volume this implies, so stakeholders see the cost of the constraint.

    • In production, recall is hard to observe because missed positives go unlabeled. Audit a random sample of unflagged items to estimate it.

  • Fixed capacity of 1,000 alerts per day:

    • Set the threshold at the score quantile where expected daily volume equals 1,000. Compute it from recent production score distributions, not the validation set, because volume and prevalence differ.

    • Alternatively, rank each day's items and send the top 1,000 (a dynamic threshold). This absorbs volume swings but makes the cutoff vary from day to day.

    • Evaluate with precision@k (yield for reviewers) and recall@k (share of all positives caught), and leave headroom for traffic spikes.

  • When constraints conflict:

    • If 95% recall needs 3,000 alerts but capacity is 1,000, no threshold satisfies both. Present the trade-off curve (recall vs volume) and let the business decide: add reviewers, accept lower recall, or improve the model.

    • Monitor score drift and re-calibrate the threshold on a regular schedule.

python
import numpy as np from sklearn.metrics import precision_recall_curve p, r, t = precision_recall_curve(y_val, s_val) ok = r[:-1] >= 0.95 t_recall = t[ok].max() # highest threshold meeting recall floor # capacity: cutoff from recent daily production scores t_capacity = np.quantile(s_prod_day, 1 - 1000 / len(s_prod_day))

Q49.
How do you translate a model's confusion matrix into expected business value or profit to compare against a baseline?

Mid

Assign a monetary value (benefit or cost) to each cell of the confusion matrix, multiply by the cell counts or rates at the deployment class mix, and sum. Then compute the same quantity for realistic baselines (current process, treat everyone, treat no one) and compare. The difference is the model's incremental value.

  • Build a cost-benefit matrix:

    • Example (churn offer): TP = saved customer value minus offer cost, FP = wasted offer cost, FN = lost customer value (or 0 relative to doing nothing), TN = 0.

    • Values must be incremental relative to a consistent reference action, or you double-count.

  • Compute expected value:

    • EV per instance = Σ P(cell) × value(cell), where P(TP) = prior(+) × TPR, P(FP) = prior(−) × FPR, and so on.

    • Use the deployment base rate, not a rebalanced test set, or the profit estimate will be wrong.

  • Compare against baselines:

    • Treat none, treat all, random targeting, and the current rule-based or human process.

    • A model with high AUC can still lose money if FP costs dominate.

  • Pick the threshold that maximizes profit:

    • Sweep thresholds and plot a profit curve. The optimum rarely sits at 0.5.

    • With calibrated probabilities, act when p × benefit(TP) > (1 − p) × cost(FP).

    • Respect constraints such as budget or capacity (for example, only 1,000 offers), which turn the problem into choosing the top-k.

  • Quantify uncertainty:

    • Bootstrap the test set to get a confidence interval on the profit lift.

    • Run sensitivity analysis on the assumed costs, then validate with an A/B test.

python
import numpy as np value = {"tp": 80, "fp": -20, "fn": 0, "tn": 0} def profit(y, p, t): pred = p >= t tp = np.sum(pred & (y == 1)); fp = np.sum(pred & (y == 0)) return tp * value["tp"] + fp * value["fp"] best_t = max(np.linspace(0, 1, 101), key=lambda t: profit(y, p, t)) lift = profit(y, p, best_t) - max(profit(y, p, 0.0), 0) # vs treat-all / treat-none

Q50.
Why can a model have excellent discrimination but terrible calibration?

Mid

Discrimination depends only on how the model ranks examples, while calibration depends on the actual probability values. Any monotonic distortion of the scores keeps the ranking (and AUC) intact but can make the probabilities badly wrong.

  • Discrimination is rank-based:

    • AUC is the probability that a random positive scores above a random negative; only order matters.

    • Example: replacing every score p with p**0.1 gives identical AUC but pushes all probabilities toward 1.

  • Calibration is value-based: Among cases predicted at 0.8, about 80% should be positive. This requires the scores to mean something absolute, not just relative.

  • Common causes of good ranking with bad calibration:

    • Resampling or class weighting: the model learns an artificial base rate, so probabilities are shifted.

    • Overfitting or overconfidence: deep nets trained with cross-entropy push outputs toward 0/1.

    • Model structure: SVM margins and boosted-tree scores are not probabilities, and Naive Bayes' independence assumption double-counts evidence, which produces extreme values.

    • Dataset shift in the base rate: the ranking still transfers, but the absolute levels do not.

  • Why it matters and the fix:

    • Good ranking is enough for top-k selection. Calibration matters when probabilities drive decisions such as expected cost, pricing or thresholds.

    • Since the problem is a monotone distortion, post-hoc recalibration (Platt scaling, isotonic regression, temperature scaling) fixes it without changing AUC.

Q51.
How do log loss and Brier score differ in how they penalize probabilistic errors?

Mid

Both are strictly proper scoring rules, but they penalize errors on different scales. Log loss uses -log(p) of the true class and is unbounded, so confident mistakes explode. Brier score uses squared error and is bounded, so even the worst mistake costs at most a fixed amount.

  • Definitions (binary case):

    • Log loss: -[y·log p + (1-y)·log(1-p)], which ranges from 0 to ∞.

    • Brier: (p - y)², which ranges from 0 to 1.

  • Shape of the penalty when y=1:

    • p=0.01 costs 4.6 in log loss and 0.98 in Brier.

    • p=0.001 costs 6.9 in log loss and 0.998 in Brier. Log loss keeps growing while Brier saturates.

    • Near the truth (p≈1), the two behave similarly.

  • Practical consequences:

    • Log loss is dominated by a few confident errors. This makes it sensitive to label noise and outliers, but it strongly discourages overconfidence and matters for rare-event risk.

    • Brier is more robust and easier to interpret (it is MSE on probabilities). It also decomposes into reliability, resolution and uncertainty, but it is less sensitive to differences among small probabilities, such as 0.01 versus 0.001.

    • Log loss is the negative log-likelihood, so it matches training with cross-entropy. Brier corresponds to a squared-error view of decision cost.

Q52.
How do you calculate expected calibration error (ECE)?

Mid

ECE bins predictions by confidence, then compares each bin's average confidence with its observed accuracy. It reports the gap averaged over bins, weighted by how many samples fall in each bin.

  • Steps:

    1. For each sample, take its confidence: the predicted probability of the top class in multiclass, or of the positive class in binary.

    2. Split [0,1] into M bins (often 10 or 15) and assign each sample to a bin.

    3. For each bin B_m, compute acc(B_m) (the fraction correct, or the positive rate in binary) and conf(B_m) (the mean confidence).

    4. Compute ECE = Σ (|B_m|/n) · |acc(B_m) − conf(B_m)|.

  • Caveats:

    • The result depends on binning choices: number of bins, and equal-width versus equal-mass (adaptive) bins. Sparse bins are noisy, and the estimate is biased.

    • ECE is not a proper scoring rule. A model that always predicts the base rate gets ECE≈0 while having no discrimination, so report it alongside log loss or Brier.

    • Top-label ECE ignores calibration of the non-top classes. Classwise ECE addresses this.

python
import numpy as np def ece(conf, correct, n_bins=10): bins = np.linspace(0, 1, n_bins + 1) idx = np.clip(np.digitize(conf, bins[1:-1]), 0, n_bins - 1) total = 0.0 for m in range(n_bins): mask = idx == m if mask.any(): gap = abs(correct[mask].mean() - conf[mask].mean()) total += mask.mean() * gap return total

Q53.
Why might two models with the same accuracy have very different log loss?

Mid

Accuracy only checks which side of the threshold a prediction falls on. Log loss scores the probability itself. Two models can make the same right and wrong calls but with very different confidence, and log loss sees that difference.

  • Accuracy discards confidence: For a positive example, p=0.51 and p=0.99 are both counted as correct.

  • Worked example (true label 1 for all four samples):

    • Model A predicts 0.6, 0.6, 0.6, 0.4. That is 75% accuracy and a log loss of about 0.61.

    • Model B predicts 0.99, 0.99, 0.99, 0.01. That is also 75% accuracy, but its log loss is about 1.16, driven by the single confident miss.

  • What drives the difference:

    • Confidence on errors: overconfident mistakes are penalized heavily, so this usually dominates.

    • Confidence on correct predictions: sharper correct predictions lower the loss.

    • Calibration: a well-calibrated model typically gets lower log loss at the same accuracy.

  • Takeaway: If probabilities feed decisions (ranking, expected value, threshold tuning), compare models on log loss or Brier score, not just accuracy.

Q54.
What is the main limitation of demographic parity when base rates differ across groups?

Mid

Demographic parity requires equal positive-prediction rates across groups, so when true base rates differ it is incompatible with an accurate classifier: even a perfect predictor violates it, and enforcing it forces errors that fall unevenly across groups.

  • What it requires: P(Ŷ=1 | A=a) = P(Ŷ=1 | A=b): the selection rate is independent of group membership, and the true label Y plays no part in the definition.

  • Why differing base rates break it:

    • If group A is 30% positive and group B is 10% positive, a perfect classifier selects 30% vs 10% and fails parity.

    • To equalize rates you must add false positives in the low-base-rate group or false negatives in the high-base-rate group (or both). Accuracy drops and FPR/FNR become unequal, so the result can violate equalized odds.

  • It can be satisfied trivially or perversely: Selecting qualified people in one group and random people in another meets parity while being clearly unfair, because the criterion never checks who is selected.

  • When it is still reasonable:

    • When the base-rate gap is itself believed to come from biased labels or historical discrimination, parity acts as a deliberate corrective.

    • When equal allocation of a resource is the actual policy goal.

  • Interview framing: fairness criteria such as parity, equalized odds and calibration generally cannot all hold when base rates differ, so pick one based on the harm you most want to avoid.

Q55.
How do you measure performance gaps across demographic subgroups that have very few samples?

Mid

Report every subgroup metric with its uncertainty, and use statistical tools that stay honest with small n: wide intervals, shrinkage toward the global estimate, and gap tests rather than raw point differences.

  • Always attach intervals:

    • For proportions (accuracy, recall), use Wilson or Clopper-Pearson intervals. Normal approximations break down near 0 or 1 and at small n.

    • Bootstrap the gap itself (subgroup minus overall, or group A minus group B) rather than only the individual metrics.

    • Check the count that actually drives the metric: recall on a group with 40 samples but 3 positives rests on 3 examples.

  • Borrow strength across groups: Bayesian hierarchical or beta-binomial models shrink noisy small-group estimates toward the population mean. This reduces false alarms while still surfacing gaps that are real.

  • Test, don't eyeball: Use permutation tests or Fisher's exact test for gaps, and correct for multiple comparisons, since many slices (especially intersectional ones) will show spurious gaps.

  • Fix the data where possible:

    • Run targeted collection or labeling to oversample small groups in the eval set.

    • Pool across time windows or evaluation rounds.

    • Merge groups only when that is semantically justified.

  • Set reporting rules: Define minimum-sample thresholds below which results are marked "insufficient evidence" rather than "no gap".

Q56.
Why is predictive parity considered a fairness criterion based on precision?

Mid

Predictive parity requires that a positive prediction is equally reliable for every group. Formally that is equal P(Y=1 | Ŷ=1, A), which is exactly the precision (PPV) computed per group.

  • Definition: PPV_a = TP_a / (TP_a + FP_a) must be equal across groups. Some definitions also require equal NPV.

  • Intuition:

    • A decision-maker acting on a "high risk" flag should face the same chance of being right regardless of the person's group. The score "means the same thing" for everyone.

    • It is closely related to calibration within groups: calibrated scores with a shared threshold tend toward similar PPV.

  • Key tension (Chouldechova / COMPAS debate):

    • With different base rates and an imperfect classifier, you cannot have equal PPV and also equal FPR and FNR.

    • COMPAS was defended on predictive parity yet criticized for unequal false positive rates. Both claims were true at once.

  • When to prefer it: when the main harm comes from acting on positives and trust in the flag matters. Prefer error-rate parity when the main harm is being wrongly flagged.

Q57.
When would you use McNemar's test to compare two classifiers?

Mid
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q58.
How does test set size affect the uncertainty of a test-set metric?

Mid
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q59.
Why do offline metric improvements sometimes fail to translate into online business gains?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q60.
A model achieves 0.98 accuracy or ROC-AUC on its offline evaluation split but falls apart once deployed. What could cause this?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q61.
How do you choose between scale-dependent, percentage-error, and normalized metrics when evaluating multiple time series of vastly different scales?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q62.
How would you evaluate a probabilistic regression or forecasting model that outputs prediction intervals rather than point estimates?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q63.
Why is computing PR-AUC with the trapezoidal rule considered less sound than average precision?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q64.
Why can comparing two models by AUC alone be misleading when only a narrow operating region matters?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q65.
Why can optimizing purely for NDCG or hit rate lead to popularity bias and poor catalog coverage?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q66.
Why evaluate retrieval/candidate generation with recall@k or precision@k, but rankers with NDCG?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q67.
Why can macro-F1 paint an overly pessimistic or noisy picture in the presence of long-tail rare classes?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q68.
How does the Brier score decompose into reliability, resolution, and uncertainty?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q69.
Why must Platt scaling or isotonic regression be fitted on a separate calibration set?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q70.
Why is using a proper scoring rule important when evaluating probabilistic predictions?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q71.
What is the difference between equal opportunity and equalized odds?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q72.
Why is it impossible to satisfy demographic parity, equalized odds, and calibration within groups simultaneously when base rates differ?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q73.
How would you choose between demographic parity, equal opportunity, and calibration-based fairness criteria for a specific application like lending or hiring?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q74.
How do you compute a bootstrap confidence interval for an offline metric?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q75.
Why is a paired bootstrap more powerful than independent bootstrapping for model comparison?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.

Q76.
How would you account for multiple comparisons when evaluating many model variants or slices?

Senior
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.