Metrics and validation
Evaluate predictive systems with appropriate data splits and error measures.
Select evaluation metrics according to the cost of false positives and false negatives.
Interview questions
Choose a question to reveal its answer.
01EasyCoreVisualWhen is precision more important than recall?
Answer
When is precision more important than recall?
True positives divided by all predicted positives.
Precision = TP/(TP + FP), when the denominator is nonzero. For a spam filter, high precision helps avoid wrongly labeling legitimate emails. Recall answers a different question: what fraction of actual spam was caught?
Measure how many flagged emails actually are spam.
from sklearn.metrics import precision_score, recall_score
y = [1, 1, 0, 0]
pred = [1, 0, 1, 0]
print(precision_score(y,pred), recall_score(y,pred))Both metrics are 0.5 here; they capture different error types.
02EasyCoreWhen should you prioritize recall?
Answer
When should you prioritize recall?
True positives divided by all actual positives.
Recall = TP/(TP + FN), when the denominator is nonzero. Changing the score threshold changes the predicted-positive set; lower thresholds normally increase or preserve recall, while precision need not change monotonically.
Measure how many real disease cases are detected.
03EasyCoreHow do you calculate specificity?
Answer
How do you calculate specificity?
True negatives divided by all actual negatives.
Measure how many healthy patients are correctly cleared.
04MediumHigh priorityWhy use the harmonic mean in F1?
Answer
Why use the harmonic mean in F1?
Harmonic mean of precision and recall.
Balance both metrics when positive identification matters.
05MediumHigh priorityWhat does ROC-AUC measure?
Answer
What does ROC-AUC measure?
Measures ranking across true-positive and false-positive rates over thresholds.
Compare a binary classifier's ranking performance independently of a fixed cutoff.
06MediumWhen is PR-AUC useful?
Answer
When is PR-AUC useful?
Area under a precision-recall curve; convention should be specified.
Evaluate ranking in a dataset with rare positives.
07MediumWhy use cross-validation instead of repeatedly testing on the test set?
Answer
Why use cross-validation instead of repeatedly testing on the test set?
Repeatedly fits and validates on different training/validation partitions.
Estimate generalization and tune hyperparameters without touching the final test.
08MediumVisualHow do you detect overfitting?
Answer
How do you detect overfitting?
Fits training-specific patterns or noise and generalizes poorly.
Start by verifying the split and absence of leakage, then compare learning curves and errors on representative held-out data. Common remedies include more suitable data, reduced complexity, regularization and early stopping. A gap may also indicate distribution shift rather than only excessive model complexity.
Observe very good training error and much worse validation error.
09HardHow do you identify underfitting?
Answer
How do you identify underfitting?
Model or training procedure fails to capture relevant structure.
Observe poor results on both training and validation sets.
10HardWhat makes a classifier well calibrated?
Answer
What makes a classifier well calibrated?
Agreement between predicted probabilities and observed event frequencies.
Check whether predictions near 0.8 are positive about 80 percent of the time.
11MediumHigh priorityHow does false positive rate relate to specificity?
Answer
How does false positive rate relate to specificity?
False positives divided by all actual negatives.
Calculate how often legitimate emails are incorrectly flagged.
12MediumHigh priorityWhen would you prefer MAE over RMSE?
Answer
When would you prefer MAE over RMSE?
Mean absolute difference between predictions and targets.
Measure house-price errors without squaring extreme deviations.
13MediumHigh priorityHow is RMSE different from MAE?
Answer
How is RMSE different from MAE?
Square root of the mean squared error, expressed in target units.
Penalize large forecast errors more than MAE does.
14MediumHigh priorityHow can the Brier score assess probability predictions?
Answer
How can the Brier score assess probability predictions?
Mean squared error between predicted binary probabilities and observed binary labels.
Evaluate the quality of probability forecasts.
15MediumHigh priorityWhy is random cross-validation risky for time series?
Answer
Why is random cross-validation risky for time series?
Evaluates future observations using models trained on earlier data.
Avoid training on future sales when evaluating a demand forecast.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.
1. TP=30, FP=10, FN=20. What is recall?
2. TP=30, FP=10. What is precision?
3. A model has 99% training accuracy and 65% validation accuracy. What should you investigate first?
Validation and hyperparameter tuning
Continue to the next set of interview questions.