Skip to content
Preptima

Machine Learning interview questions and answers

The modelling half of an ML loop: supervised and unsupervised methods, features and leakage, metric choice, imbalance, deep learning foundations, forecasting and ranking.

24 published across 8 topics.

Linear and logistic models, trees and gradient boosting, regularisation, and choosing a family from the data and the constraints rather than by habit.

mediumConcept

What does regularisation do to a model, and how do L1 and L2 differ in their effect?

Regularisation adds a penalty on coefficient size to the objective, so each coefficient must buy its own weight with error. L2 shrinks smoothly and spreads weight across correlated features; L1 has a constant gradient towards zero, so it drives coefficients exactly to zero and selects features as a side effect.

5 minentry, mid, senior
All 3 in Supervised Learning

Encoding, scaling and interaction terms, target and temporal leakage, train-serve skew, and the features that quietly encode the label.

mediumConceptCoding

One of your features is a postcode with about 40,000 distinct values. How do you encode it?

One-hot is unusable at that width, so the options are frequency encoding, smoothed target encoding, hashing, or a library's native categorical handling. Target encoding is the strongest and the most dangerous, because it must be fitted inside each fold or it leaks the label. Use this categorical encoding answer to show the decision, trade-off, and evidence rather than a memorised definition.

5 minmid, senior
hardDesignScenario

Where does train-serve skew come from, and how do you stop it?

Train-serve skew is a mismatch between features used in training and features produced at serving time. Prevent it with shared transformations, point-in-time joins, feature logging, schema checks and monitoring of served feature distributions. It also connects feature store to the point an interviewer is testing.

6 minmid, senior, staff
mediumConceptScenario

What is target leakage, and how would you catch it before the model ships?

Target leakage happens when a feature contains information that would not be available at prediction time. Catch it by auditing feature creation times, window boundaries, post-label columns and suspiciously strong validation performance. Use this data leakage answer to show the decision, trade-off, and evidence rather than a memorised definition.

5 minmid, senior, staff
All 3 in Feature Engineering & Leakage

Cross-validation that respects structure, ROC versus precision-recall, calibration, threshold selection, and tying a metric to a business decision.

All 3 in Model Evaluation & Metrics

Fraud and failure-scale imbalance, resampling and class weights, why accuracy is meaningless here, and evaluating at the operating point you will run.

hardConceptScenario

How do you choose the decision threshold for a classifier, and what makes it move?

Choose a classifier decision threshold from calibrated probability, false-positive cost, false-negative cost and operational capacity. The threshold changes when costs, prevalence, calibration or alert budget changes. It also connects cost sensitive learning to the point an interviewer is testing.

6 minmid, senior, staff
hardConcept

Class weights, oversampling, undersampling, SMOTE. What does each one cost you?

Class weights, oversampling, undersampling and SMOTE are ways to train on imbalanced data, but none creates new signal. They change loss, sample frequency or geometry, so validation, calibration and threshold choice must be handled carefully. Use this class imbalance answer to show the decision, trade-off, and evidence rather than a memorised definition.

5 minmid, senior, staff
All 3 in Imbalanced & Rare Events

Clustering and its evaluation, dimensionality reduction, density and isolation methods, and detecting anomalies with no labels to learn from.

mediumConceptDesignScenario

You need to flag anomalies and nobody has labelled a single one. How do you build it?

Model what normal looks like and score deviation from it, using distance or density methods, an isolation forest, or reconstruction error from an autoencoder. Then set the threshold from how many alerts the team can investigate per day, because an unlabelled score distribution cannot tell you where to cut.

4 minmid, senior, staff
All 3 in Unsupervised & Anomaly Detection

Backpropagation, optimisers and learning-rate behaviour, normalisation and regularisation, attention and transformers, and when a neural net is not the answer.

mediumConcept

What is backpropagation doing, and what does a vanishing gradient look like in practice?

Backpropagation applies the chain rule backwards through a network, reusing each layer's cached activations to get every parameter's gradient in one pass. Gradients vanish when many small factors multiply, and it shows as a stalled loss with early-layer weights barely moving while the last layers still train. It also connects vanishing gradient to the point an interviewer is testing.

4 minmid, senior, staff
mediumConceptScenario

How do you choose an optimiser and a learning-rate schedule?

Choosing an optimizer and learning rate schedule starts with the learning rate, then the optimizer. AdamW is a strong default, SGD with momentum can generalise well when tuned, and warmup plus decay usually matters more than the optimizer name. Use this optimisers answer to show the decision, trade-off, and evidence rather than a memorised definition.

5 minmid, senior, staff
mediumConceptDesign

When is a neural network the wrong choice?

On small and medium tabular data, where gradient-boosted trees usually match it for a fraction of the effort; where a decision must be explained exactly rather than approximately; and where a tight CPU latency or memory budget makes it unservable. The simpler model then wins on every axis that matters.

5 minmid, senior, staff, lead
All 3 in Deep Learning Foundations

Stationarity and seasonality, backtesting without lookahead, horizon and hierarchy, and why a random split ruins a forecasting model.

mediumConceptScenario

Why does a random train-test split ruin a forecasting model?

A random train-test split ruins a forecasting model by leaking future observations into training. Use time-based holdouts or rolling-origin backtesting, and build every feature only from data available before the forecast timestamp. Use this time series answer to show the decision, trade-off, and evidence rather than a memorised definition.

5 minentry, mid, senior, staff
All 3 in Time Series & Forecasting

Collaborative and content signals, candidate generation then ranking, cold start, position bias and feedback loops, and offline-online metric divergence.

hardDesignScenario

How do you handle cold start for a brand new user and a brand new item?

Fall back to content features and segment popularity while behavioural signal is absent, then blend towards collaborative scores as interactions accumulate. New items also need guaranteed exploration impressions, or the already-popular items take all the traffic and nothing can dislodge them.

5 minmid, senior, staff, lead
All 3 in Recommenders & Ranking