ML ENGINEERING · ROUND 1 OF 3
ML fundamentals
The interviewer checks you can diagnose models, pick the right tools and avoid the classic traps.
Question 1 of 8
Your model's validation error is much worse than you need. How do you decide what to do next?
Answer out loud first, then open the model answer.
View model answer
I'd compare training and validation error. If both are high, the model is underfitting (high bias), so I'd add capacity, better features or train longer. If training error is low but validation is much higher, it's overfitting (high variance), so I'd regularise, simplify or add data.
Learning curves make this concrete: if the two curves have converged at a high error, more data won't help; if there's still a gap, it will. I'd also rule out data problems such as label noise or leakage before changing the model.
What the interviewer listens for
- Compares train vs validation error
- Bias → more capacity/features; variance → regularise/more data
- Uses learning curves
- Checks data quality first
Lessons: The Bias–Variance Trade-off, Learning Curves and Debugging Models
Question 2 of 8
What is data leakage? Give two examples and how you'd prevent them.
Answer out loud first, then open the model answer.
View model answer
Leakage is when information that won't be available at prediction time gets into training, so offline scores look great and production fails. One example: fitting a scaler or doing feature selection on the full dataset before cross-validation. Another: a feature computed from the future, like 'refund issued' when predicting fraud at checkout.
To prevent it, I put all preprocessing inside the cross-validation pipeline, split by time for time-dependent problems, and build features point-in-time, using only data known before the prediction.
What the interviewer listens for
- Clear definition: unavailable info at prediction time
- Preprocessing-before-split example
- Future/target-derived feature example
- Pipelines, time-based splits, point-in-time features
Lessons: Cross-Validation & Data Leakage, Feature Engineering
Question 3 of 8
Only 2% of your examples are positive. How do you train and evaluate the model?
Answer out loud first, then open the model answer.
View model answer
For evaluation I'd drop accuracy, since predicting all negatives gets 98%. I'd use precision, recall and PR-AUC, and pick the threshold from business costs: if a miss costs much more than a false alarm, the threshold should be low.
For training, I'd often keep the natural data and use class weights, or simply move the threshold. Resampling methods like SMOTE can help some models but can also distort probabilities. I'd use stratified splits so every fold has positives.
What the interviewer listens for
- Accuracy is misleading
- Precision/recall/PR-AUC
- Threshold set by costs
- Class weights or threshold vs resampling trade-offs
Lessons: Class Imbalance, Thresholds & Misclassification Costs, ROC-AUC vs PR-AUC
Question 4 of 8
Random forest or gradient boosting: how do they differ, and which would you try first on tabular data?
Answer out loud first, then open the model answer.
View model answer
A random forest trains many deep trees independently on bootstrap samples with random feature subsets, and averages them, which mainly reduces variance. Gradient boosting adds small trees one after another, each fitting the current errors, which mainly reduces bias.
Boosting usually wins on tabular data but needs tuning: learning rate, number of trees with early stopping, depth. A random forest is a robust, low-tuning baseline. I'd start with the forest as a baseline and then tune a boosting model.
What the interviewer listens for
- Bagging (parallel, variance) vs boosting (sequential, bias)
- Boosting can overfit; needs early stopping
- Forest = strong low-effort baseline
- Practical order of trying
Lessons: Random Forest, Gradient Boosting, Ensembles: Voting, Stacking and Bagging vs Boosting
Question 5 of 8
Explain L1 versus L2 regularisation. When would you use each?
Answer out loud first, then open the model answer.
View model answer
Both add a penalty on weight size to the loss. L2 penalises squared weights and shrinks them smoothly towards zero, which handles correlated features well. L1 penalises absolute values, and its constant pull drives some weights exactly to zero, which selects features.
I'd use L2 as the default, L1 when I expect only a few features to matter and want a sparse model, and Elastic Net when features are many and correlated.
What the interviewer listens for
- Penalty on weight size
- L1 → sparsity; L2 → shrinkage
- Why: L1's constant gradient vs L2's fading one
- Elastic Net for correlated features
Question 6 of 8
Explain logistic regression to me, including how you'd interpret a coefficient.
Answer out loud first, then open the model answer.
View model answer
Logistic regression predicts a probability for a binary outcome. It computes a linear score from the features, treats that score as the log-odds, and passes it through a sigmoid to get a probability. It's trained by minimising log-loss, which punishes confident wrong predictions heavily.
A coefficient β means one unit more of that feature adds β to the log-odds, which multiplies the odds by e^β, holding other features fixed. So β = 0.7 roughly doubles the odds.
What the interviewer listens for
- Linear score = log-odds; sigmoid → probability
- Trained with log-loss
- Coefficient → odds ratio e^β
- Holding other features fixed
Lessons: Logistic Regression
Question 7 of 8
How would you encode a categorical feature with thousands of values, like a pincode?
Answer out loud first, then open the model answer.
View model answer
One-hot encoding creates thousands of sparse columns, which works for linear models but is clumsy for trees. Options: frequency encoding, target encoding, or learned embeddings in a neural network.
Target encoding is powerful but leaks if a row's own label shapes its value, so I'd compute it out-of-fold with smoothing towards the overall mean, so rare categories don't get noisy values. I'd also group very rare values into an 'other' bucket.
What the interviewer listens for
- One-hot limits at high cardinality
- Target, frequency or embedding options
- Out-of-fold + smoothing to avoid leakage
- Handling rare categories
Lessons: Encoding Categorical Features
Question 8 of 8
Which evaluation metric would you choose for a fraud model, and why not ROC-AUC alone?
Answer out loud first, then open the model answer.
View model answer
Fraud is rare, so I'd focus on the positive class: precision tells me how many flags are real, and recall how much fraud I catch. PR-AUC summarises that trade-off across thresholds.
ROC-AUC can look excellent because the false-positive rate stays tiny with millions of legitimate transactions, even when false alarms swamp the review team. In the end I'd report precision and recall at the operating threshold, and the expected cost.
What the interviewer listens for
- Focus on positives: precision and recall
- PR-AUC for rare classes
- Why ROC-AUC is misleading here
- Operating threshold and cost
Lessons: Classification Metrics, ROC-AUC vs PR-AUC