Skip to main content

Interview prep

Top 25 Machine Learning Engineer interview questions

13 of these 25 are scenario, use-case or real-life questions, the kind that decide an interview. Each has a short answer to say out loud, the explanation behind it, and an example you can tell.
Practice out loud
  1. 1ConceptBeginner 1

    What is the difference between supervised and unsupervised learning?

    Short answer

    Supervised learning trains on examples with known answers, such as emails labelled spam or not, and learns to predict the label. Unsupervised learning has no labels and finds structure on its own, such as grouping customers into segments. Language model pre-training is often called self-supervised: the next word is the label.

    The explanation

    In supervised learning you have input and output pairs and measure success by comparing predictions with the true outputs, for example classification and regression. In unsupervised learning you only have inputs and look for patterns: clustering, dimensionality reduction, anomaly detection.

    Self-supervised learning sits between them: the labels come from the data itself. Predicting the next token in text needs no human labelling, which is why models can train on enormous corpora. Fine-tuning a model on labelled examples is then supervised again.

    An example you can use in the interview

    If a telecom company has past customers labelled 'left' or 'stayed', a churn model trained on them is supervised learning. If it only has usage data with no labels and wants to discover natural customer groups, such as night-time data users or mostly-calls users, clustering them is unsupervised learning. Language models learn by predicting the next word in text, which is called self-supervised.

    They may follow up with

    • Where does reinforcement learning fit?
    • Why is next-token prediction called self-supervised?

    Avoid

    • Saying unsupervised means no data is needed
    • Mixing up clustering and classification

    Practice this oneLesson: Unsupervised learning

  2. 2ConceptBeginner 1

    What is overfitting, and how do you spot it?

    Short answer

    Overfitting is when a model learns the training data too closely, including its noise, so it does well on training data but badly on new data. You spot it when training performance keeps improving while validation performance stops improving or gets worse.

    The explanation

    A model that memorises rather than generalises looks great in training and fails in use. The standard check is to hold out data the model never trains on and compare scores. A large gap between training and validation scores is the signal.

    Common remedies are more and more varied data, a simpler model, regularisation, early stopping and data augmentation. The same idea appears with LLM apps: a prompt tuned on five examples can overfit to them, which is why you test prompts on a separate, varied set.

    An example you can use in the interview

    A student who memorises last year's question paper scores perfectly on that paper and badly on a new one. A model does the same: on a house-price dataset, my deep decision tree had almost zero error on training data but a much larger error on validation. Plotting both errors against tree depth showed validation error rising after depth eight, which is where overfitting started.

    They may follow up with

    • How does the idea of overfitting apply to prompt engineering?
    • What is the opposite problem, and how does it look?

    Avoid

    • Judging a model only by its score on training data
    • Thinking more training always helps

    Practice this oneLesson: Cross-validation and leakage

  3. 3ConceptIntermediate 1

    Explain the bias-variance trade-off.

    Short answer

    Bias is error from a model that is too simple to capture the pattern, so it underfits. Variance is error from a model so flexible that it fits noise, so it overfits. Making a model more complex usually lowers bias and raises variance; you look for the complexity that gives the lowest error on validation data.

    The explanation

    A straight line fitted to curved data has high bias: it is wrong in the same way on every dataset. A very deep decision tree has high variance: train it on a slightly different sample and you get a very different tree. Total error on new data is roughly bias squared plus variance plus noise you cannot remove.

    In practice you see it in learning curves. High bias shows as poor scores on both training and validation data; high variance shows as a big gap between them. Remedies differ: for bias, add features or use a more flexible model; for variance, get more data, regularise, simplify, or average many models, which is what random forests do.

    An example you can use in the interview

    Predicting a flat's rent from only its area in square feet is high bias: it misses location, floor and furnishing, so it is wrong everywhere. A model that memorises every training flat, down to the owner's name, is high variance: perfect on training data, poor on new listings. I would tune complexity, for example tree depth, using validation error to find the sweet spot.

    They may follow up with

    • How would a learning curve look for a high-variance model?
    • Why does bagging reduce variance?

    Avoid

    • Mixing up which of bias and variance means underfitting
    • Saying more data fixes high bias

    Practice this oneLesson: Regression

  4. 4ConceptIntermediate 1

    What do L1 and L2 regularisation do?

    Short answer

    Both add a penalty on the size of the model's weights to the loss, which discourages overfitting. L2 (ridge) penalises squared weights and shrinks them all smoothly towards zero. L1 (lasso) penalises absolute weights and pushes many to exactly zero, so it also selects features. The strength is a hyperparameter you tune on validation data.

    The explanation

    Without a penalty, a model with many features can give large weights to noise. Regularisation trades a little training error for simpler weights that generalise better.

    Use L2 when many features each carry a little signal, and L1 when you suspect only a few matter and want a sparse, explainable model. Elastic net mixes both and behaves better when features are correlated, where lasso tends to pick one at random. Scale features first, because the penalty treats all weights alike. In neural networks, L2 appears as weight decay, alongside other regularisers such as dropout.

    An example you can use in the interview

    On a model predicting customer spend with 200 features, plain linear regression overfitted. Ridge (L2) shrank all the weights and improved validation error. Lasso (L1) set about 150 weights to exactly zero, leaving a smaller model the business could understand, with similar error. I chose the penalty strength by cross-validation.

    They may follow up with

    • Why should you scale features before regularising?
    • What happens as the penalty strength grows very large?

    Avoid

    • Saying L2 sets weights to exactly zero
    • Not scaling features first

    Practice this oneLesson: Regression

  5. 5ConceptBeginner 3

    What is the difference between linear and logistic regression?

    Short answer

    Linear regression predicts a number, such as a house price, by fitting a weighted sum of the features with squared error loss. Logistic regression predicts the probability of a class, such as spam or not, by passing that weighted sum through a sigmoid and training with log loss; you then pick a threshold to make a decision.

    The explanation

    Despite its name, logistic regression is a classification model. Its weights are interpretable as changes in the log odds, which is why it is still used in credit scoring and medicine where explanations matter.

    Both are strong baselines: fast, explainable and hard to beat when relationships are roughly linear. Both benefit from scaling and regularisation. For more than two classes, logistic regression extends to softmax regression.

    An example you can use in the interview

    If I want to predict a used car's resale price in rupees, I use linear regression: a weighted sum of age, kilometres and brand gives a number. If I want to predict whether a customer will buy an extended warranty, I use logistic regression: the same kind of weighted sum goes through a sigmoid to give a probability, say 0.72, and I choose a threshold, perhaps 0.5 or whatever suits the sales team, to decide whom to call.

    They may follow up with

    • Why not use linear regression for a yes or no target?
    • How do you interpret a logistic regression weight?

    Avoid

    • Calling logistic regression a regression model for numbers
    • Forgetting the threshold step

    Practice this oneLesson: Classification

  6. 6ConceptIntermediate 2

    Explain precision and recall with an example.

    Short answer

    Precision is the share of items you flagged that were truly relevant; recall is the share of all relevant items that you found. A spam filter that flags only obvious spam has high precision but misses some spam, so lower recall. Which matters more depends on the cost of each kind of mistake.

    The explanation

    Precision = true positives / (true positives + false positives). Recall = true positives / (true positives + false negatives). Raising one often lowers the other, which is why F1, their harmonic mean, is used as a single number.

    In retrieval for RAG, recall at k asks whether the chunk you needed was in the top k results, and precision asks how much of what you retrieved was useful. Missing the needed chunk (low recall) usually hurts answers more than retrieving a few extra chunks, so teams often tune for recall first, then rerank.

    An example you can use in the interview

    Imagine a bank's fraud alert. Of 100 transactions it flags, 80 are really fraud: that is 80% precision. If there were 200 frauds in total and it caught those 80, recall is 40%. Lowering the threshold might catch 150 frauds but flag many more honest customers, so the bank chooses based on what each kind of mistake costs.

    They may follow up with

    • In a medical screening test, which matters more and why?
    • How do precision and recall apply to RAG retrieval?

    Avoid

    • Swapping the definitions
    • Quoting accuracy on a heavily imbalanced dataset

    Practice this oneLesson: Choosing a metric

  7. 7ConceptIntermediate 2

    What is the difference between a random forest and gradient boosting?

    Short answer

    Both combine many decision trees. A random forest trains deep trees independently on random samples of rows and features and averages them, which mainly cuts variance. Gradient boosting trains shallow trees one after another, each fixing the errors of the ones before, which mainly cuts bias. Boosting is often more accurate on tables but needs more careful tuning.

    The explanation

    Random forests are forgiving: sensible defaults work, they rarely overfit badly as you add trees, and training parallelises. Gradient boosting libraries such as XGBoost and LightGBM usually win on tabular data competitions, but you must tune the learning rate, number of trees, tree depth and regularisation, and use early stopping on a validation set because adding trees can overfit.

    Both give feature importance scores, though these can mislead with correlated features; permutation importance or SHAP values are more reliable. For a first model on a table, a random forest is a strong baseline; gradient boosting is usually the one you ship after tuning.

    An example you can use in the interview

    On a credit-default dataset I compared both. The random forest, with 500 deep trees averaged, gave a solid result with almost no tuning. Gradient boosting with LightGBM, building shallow trees one after another to correct the previous errors, scored better but overfitted until I tuned the learning rate, tree depth and early stopping. I would start with a forest as a strong baseline and move to boosting when the extra accuracy matters.

    They may follow up with

    • Why does adding trees to a random forest not cause overfitting the way it can in boosting?
    • How does the learning rate interact with the number of trees?

    Avoid

    • Saying boosting trains trees in parallel
    • Forgetting early stopping when boosting

    Practice this oneLesson: Trees and gradient boosting

  8. 8ConceptPro 1

    Why do we split data into training, validation and test sets?

    Short answer

    To measure how a model or system performs on data it has not seen. You train on the training set, tune choices on the validation set, and report final performance once on the test set. If you tune on the test set, your score becomes optimistic and stops predicting real-world results.

    The explanation

    Each tuning decision leaks a little information about the data you tuned on. Keeping a test set untouched until the end gives an honest estimate. For time-based data, split by time so you do not train on the future.

    The same discipline applies to LLM apps: keep a fixed eval set, and if you iterate heavily on it, keep a second held-out set to confirm the improvement is real. Make sure the sets reflect real user inputs, including messy and adversarial ones.

    An example you can use in the interview

    It is like exam preparation: you practice on past papers (training), take mock tests to decide what to revise (validation), and sit the real exam once (test). If you keep peeking at the real exam paper while preparing, your score there no longer tells you how you will do on a new exam. For time-based data, such as sales, I split by date so the test set is the most recent period.

    They may follow up with

    • How would you split data that changes over time?
    • How does this apply when you only change prompts, not train a model?

    Avoid

    • Tuning repeatedly on the test set
    • Letting near-duplicate examples appear in both training and test data

    Practice this oneLesson: Cross-validation and leakage

  9. 9ConceptIntermediate 2

    Explain backpropagation in simple terms.

    Short answer

    Backpropagation works out how much each weight contributed to the error. After a forward pass computes the prediction and loss, it applies the chain rule backwards, layer by layer, to get the gradient of the loss for every weight. An optimiser such as gradient descent then nudges each weight in the direction that reduces the loss.

    The explanation

    Think of a long chain of simple functions. The chain rule says the effect of an early weight on the final loss is the product of the local effects along the path. Backpropagation computes these efficiently by reusing results from later layers as it moves back, so getting every gradient costs only a small multiple of one forward pass, not one pass per weight.

    Frameworks such as PyTorch do this automatically: they record operations during the forward pass and call backward to fill in gradients. You still need to understand it to diagnose problems such as vanishing or exploding gradients, and to know why you zero gradients between steps.

    An example you can use in the interview

    Think of a team that lost a match by 30 runs. Backpropagation is the review that works backwards from the result to ask how much each decision contributed: the bowling change, the batting order, a dropped catch. In a network, the chain rule does this for every weight, giving each one a gradient, and gradient descent then adjusts each a little so the next 'match' goes better.

    They may follow up with

    • What is the role of the learning rate?
    • Why do we call optimizer.zero_grad in PyTorch?

    Avoid

    • Confusing backpropagation (computing gradients) with gradient descent (updating weights)
    • Saying it needs a separate pass per weight

    Practice this oneLesson: Neural networks

  10. 10ConceptIntermediate 3

    What are vanishing and exploding gradients, and how are they addressed?

    Short answer

    In deep networks, gradients are products of many terms. If those terms are mostly small, gradients shrink towards zero and early layers stop learning; if large, they blow up and training diverges. Fixes include ReLU-style activations, careful weight initialisation, normalisation layers, residual connections and, for exploding gradients, gradient clipping.

    The explanation

    Sigmoid and tanh activations saturate, so their derivatives are tiny for large inputs, which made deep networks and plain recurrent networks hard to train. ReLU keeps a derivative of one for positive inputs. He or Xavier initialisation keeps the scale of signals steady across layers. Batch or layer normalisation stabilises activations.

    Residual connections, used in ResNets and in every transformer block, give gradients a direct path back through the network, which is a big reason very deep models train at all. LSTMs and GRUs used gates for the same reason in recurrent networks. Gradient clipping caps the norm of the gradient to stop a single bad step from wrecking training.

    An example you can use in the interview

    If each layer multiplies the gradient by about 0.5, after 20 layers it is around one-millionth of its size, so the first layers barely learn; that is vanishing. If each multiplies by 2, it grows about a million times and training blows up; that is exploding. ReLU activations, good initialisation, batch or layer normalisation and residual connections keep gradients healthy, and clipping caps them when they explode.

    They may follow up with

    • Why do residual connections help gradients?
    • How would you notice exploding gradients during training?

    Avoid

    • Only naming one cause
    • Saying ReLU solves every problem (it has dead units)

    Practice this oneLesson: Neural networks

  11. 11ConceptIntermediate 2

    Why do convolutional neural networks work well for images?

    Short answer

    Convolutions slide small learned filters across the image, so the same weights detect a pattern such as an edge anywhere in the picture. That weight sharing needs far fewer parameters than a fully connected layer and builds in translation equivariance. Stacked layers combine edges into textures, parts and objects, and pooling or strides shrink the image as features grow richer.

    The explanation

    A 224 by 224 colour image has about 150,000 input values; a dense layer on that is huge and ignores that nearby pixels relate. Convolution uses local receptive fields: each output looks only at a small patch, and stacking layers widens what deeper units see.

    Modern practice rarely trains a CNN from scratch: you take a pretrained backbone such as a ResNet or EfficientNet and fine-tune it. Vision transformers now compete with CNNs on large datasets, but CNNs remain strong and efficient, especially on smaller data and edge devices.

    An example you can use in the interview

    To recognise a cat in a photo, it should not matter whether the cat is in the top corner or the centre. A convolution uses the same small filter, say one that detects a vertical edge, everywhere in the image, so it finds that edge wherever it is, with very few weights. Early layers find edges, later ones combine them into ears and eyes, and the final layers recognise the cat.

    They may follow up with

    • What does a 1 by 1 convolution do?
    • When might a vision transformer beat a CNN?

    Avoid

    • Saying CNNs are rotation invariant by design
    • Ignoring transfer learning

    Practice this oneLesson: CNNs for images

  12. 12ConceptIntermediate 3

    Why does experiment tracking matter, and what do you record?

    Short answer

    Without tracking you cannot reproduce or compare results, and you forget which run produced the model in production. Record the code version, data version, parameters, metrics, the environment and the model artefact for every run, in a tool such as MLflow or Weights and Biases.

    The explanation

    Tracking turns 'I think the second run was better' into a table you can sort. It also answers audit questions later: which data trained this model, and who approved it.

    Good habits: log automatically from the training script, tag runs with the question they answer, keep the evaluation set fixed so scores are comparable, and register the chosen model in a model registry with its run linked. For LLM work the same applies to prompts and model versions.

    An example you can use in the interview

    Three months after shipping a churn model, a manager asked why the current version did better than the January one. Because every run in MLflow had the git commit, data snapshot ID, hyperparameters and metrics, I could show that the gain came from adding two features, not from tuning, and rebuild the January model exactly to compare.

    They may follow up with

    • How would you make a run fully reproducible?
    • What is a model registry for?

    Avoid

    • Tracking metrics but not data or code versions
    • Comparing runs evaluated on different data

    Practice this oneLesson: Experiment tracking and model registry

  13. 13Use caseIntermediate 1

    How does k-means work, and how do you choose k?

    Short answer

    k-means picks k centres, assigns each point to its nearest centre, moves each centre to the mean of its points, and repeats until assignments stop changing. To choose k, try several values and look at the elbow in within-cluster distance, the silhouette score, and above all whether the clusters are useful for the business question.

    The explanation

    k-means assumes roughly round clusters of similar size and is sensitive to feature scale and outliers, so scale features first. It finds a local optimum, so run it several times with different starts; k-means++ initialisation helps.

    The elbow method plots within-cluster sum of squares against k and looks for where improvement flattens. Silhouette measures how much closer points are to their own cluster than to the next one. Neither is decisive: for customer segments, the right k is often the number of groups the marketing team can actually act on. If clusters are irregular in shape, consider DBSCAN or a Gaussian mixture.

    An example you can use in the interview

    For a retail chain's customer segments, I ran k-means for k from 2 to 10 on spending features. The elbow was around 4 to 6 and the silhouette score peaked at 5. But the marketing team found that two of the five clusters needed the same campaign, so we used 4, because each matched a different offer. The number that is useful to the business matters more than the best score.

    They may follow up with

    • Why must features be scaled for k-means?
    • When would DBSCAN be a better choice?

    Avoid

    • Not scaling features
    • Treating the elbow as a precise answer

    Practice this oneLesson: Unsupervised learning

  14. 14Use caseBeginner 3

    How do you deal with missing values in a dataset?

    Short answer

    First find out why values are missing, because that decides the fix. Then drop rows or columns only if little is lost, impute with the median, most frequent value or a model, and often add a flag saying the value was missing. Fit any imputation on training data only.

    The explanation

    Missing can carry meaning: a blank income field on a loan application may itself predict risk, so a missing-value indicator often helps. Values missing completely at random are the easy case; values missing for a reason need care.

    In pandas, start with isna().sum() to see how much is missing per column. Use a scikit-learn pipeline with SimpleImputer so cross-validation refits it per fold. Gradient boosting libraries can handle missing values natively, which is worth mentioning.

    An example you can use in the interview

    In a dataset of loan applicants, 'monthly income' was missing for about 12% of rows. Checking why, I found most were self-employed applicants who left it blank, so missingness itself carried information. I imputed the median income within each occupation, fitted only on the training split, and added an 'income_missing' flag. The flag turned out to be one of the more useful features.

    They may follow up with

    • Why fit the imputer on training data only?
    • When would you drop a column instead?

    Avoid

    • Filling with the mean computed on all data
    • Dropping rows without checking how many are lost

    Practice this oneLesson: Tables with pandas

  15. 15Real lifeIntermediate 1

    Give an example of feature engineering that made a model better.

    Short answer

    Turn raw data into signals the model can use. For a food delivery time model, a raw timestamp helps little, but hour of day, day of week, whether it is a festival day, distance from restaurant to customer and the restaurant's recent average preparation time capture what really drives delay. Check each feature on validation data and watch for leakage.

    The explanation

    Good answers name the domain reasoning, not just the technique. Common transforms: extracting parts of dates, ratios such as amount over the customer's average, counts and aggregates over a time window, text length or keyword flags, and encodings for categories, such as target encoding fitted inside training folds.

    Then prove value: compare validation scores with and without the feature, and look at feature importance. Be careful that aggregates use only past data at prediction time. Tree models need less scaling and fewer interaction features than linear models, which is worth saying if you mention model choice.

    An example you can use in the interview

    On a project predicting late deliveries for a grocery app, the raw order time and addresses gave a weak model. I added hour of day, whether it was raining from a weather feed, the store's average picking time over the last hour, and road distance instead of straight-line distance. The rain and recent-picking-time features made the biggest difference on validation data, and I checked neither used information from after the order.

    They may follow up with

    • How would you encode a category with thousands of values?
    • How do you know a new feature really helped?

    Avoid

    • Listing techniques with no domain reason
    • Building aggregates that include the future

    Practice this oneLesson: Feature engineering

  16. 16ScenarioIntermediate 2

    What is data leakage, and how do you prevent it?

    Short answer

    Leakage is when information that would not be available at prediction time gets into training, so validation scores look great but production disappoints. Causes include features computed from the future or the target, and preprocessing fitted on the whole dataset. Prevent it by splitting first, fitting every transform inside the training fold, and splitting by time or group where needed.

    The explanation

    Classic examples: predicting loan default with a feature like "number of collection calls", which only exists after default; scaling or imputing with statistics from the full dataset before splitting; or random splits on time-series data so the model sees the future.

    The defence is mostly discipline. Split before any exploration that drives modelling choices. Put preprocessing in a pipeline so cross-validation refits it on each training fold. Use time-based splits for anything that changes over time, and group splits when the same customer or patient appears in many rows. A suspiciously high score is itself a warning sign worth investigating.

    An example you can use in the interview

    In a hospital readmission model, the validation AUC was suspiciously high. One feature was 'number of follow-up appointments booked', which is only known after discharge, around the time a readmission would happen. Another was scaling fitted on the whole dataset. Removing the first, fitting the scaler inside each fold and splitting by patient brought the score down to something believable that held up on new data.

    They may follow up with

    • How would you split data for a model predicting next month's sales?
    • Why does fitting a scaler before the split leak information?

    Avoid

    • Scaling or imputing on the full dataset before splitting
    • Random splits on time-ordered data

    Practice this oneLesson: Cross-validation and leakage

  17. 17ScenarioIntermediate 2

    How do you handle a heavily imbalanced classification problem, such as fraud detection?

    Short answer

    First pick the right metric: accuracy is useless when 99.5% of cases are normal, so use precision, recall, F1 or the area under the precision-recall curve. Then use class weights or resampling, tune the decision threshold for the business cost of each error, and validate with stratified splits.

    The explanation

    With one fraud case in two hundred, a model that always says "not fraud" is 99.5% accurate and worthless. The real question is the cost of a missed fraud versus a false alarm that annoys a customer, so agree that with the business before modelling.

    Techniques: class weights so mistakes on the rare class cost more; undersampling the majority or oversampling the minority, done only inside training folds; models such as gradient boosting that cope well with imbalance; and choosing the threshold on a precision-recall curve instead of using 0.5. Use stratified cross-validation so each fold has some positive cases, and report results at the threshold you will actually use.

    An example you can use in the interview

    On a UPI fraud dataset where only a tiny share of transactions were fraud, a model that predicted 'not fraud' every time scored over 99% accuracy and was useless. I switched to precision-recall AUC, used class weights in LightGBM, and set the threshold with the fraud team: missing a fraud cost far more than a false alert, but analysts could review only a few hundred alerts a day, so we picked the threshold that filled that capacity with the highest-risk cases.

    They may follow up with

    • Why can SMOTE inside the whole dataset leak?
    • How would you choose the threshold?

    Avoid

    • Reporting accuracy
    • Resampling before the train-test split

    Practice this oneLesson: Choosing a metric

  18. 18ScenarioIntermediate 1

    How would you tell whether a new model really performs better in an A/B test?

    Short answer

    Decide the metric and the smallest effect worth detecting before starting, work out the sample size needed, randomly split users, and run for full weeks. Then compare the groups with a significance test and a confidence interval, and only call a winner when the interval excludes zero and the effect is large enough to matter.

    The explanation

    A p-value below 0.05 means a difference this large would be unlikely if there were truly no effect; it is not the probability that the new model is better. Peeking daily and stopping when it looks good inflates false positives, so fix the duration or use a sequential method.

    Watch for novelty effects, weekday patterns and segments that react differently, and check guardrail metrics such as latency or complaints. For ML, offline gains often shrink online, which is exactly why the test matters.

    An example you can use in the interview

    On a food app's 'reorder' recommendations, we decided up front that a 1-point rise in reorder rate was the smallest change worth shipping, which needed about 40,000 users per group for two full weeks. After one week the new model looked 2 points better, and a product manager wanted to stop early. I explained that weekends behave differently and that peeking inflates false wins. At two weeks the difference was 0.6 points with an interval that included zero, so we did not ship it.

    They may follow up with

    • What is wrong with stopping the test as soon as it looks significant?
    • What does a 95% confidence interval tell you?

    Avoid

    • Misreading the p-value
    • Peeking and stopping early

    Practice this oneLesson: Statistics for machine learning

  19. 19ScenarioIntermediate 2

    Your neural network overfits. What do you try?

    Short answer

    Confirm it first: training loss keeps falling while validation loss rises. Then get more or augmented data, add regularisation such as dropout and weight decay, use early stopping on validation loss, shrink the model, or start from a pretrained model. Change one thing at a time and compare on the same validation set.

    The explanation

    Data augmentation is often the biggest win for images and audio: random crops, flips, colour changes or noise make the model see varied examples. Dropout randomly zeroes activations during training; weight decay penalises large weights; early stopping keeps the checkpoint with the best validation loss.

    Also check for problems that look like overfitting: leakage between training and validation, a validation set from a different distribution, or a bug in evaluation mode, such as forgetting model.eval so dropout and batch norm behave as in training.

    An example you can use in the interview

    On a product-image classifier for an e-commerce catalogue, training accuracy reached 99% while validation stalled around 80% and validation loss rose after epoch six. I first added data augmentation, such as flips, crops and colour changes, which helped most, then dropout and weight decay, and early stopping on validation loss. Finally I switched to a pretrained backbone, which gave the biggest jump. I changed one thing at a time to know what helped.

    They may follow up with

    • Why does model.eval matter for dropout and batch norm?
    • How does data augmentation reduce overfitting?

    Avoid

    • Changing many things at once
    • Forgetting to switch to evaluation mode

    Practice this oneLesson: PyTorch

  20. 20Use caseIntermediate 2

    What is transfer learning, and when would you use it?

    Short answer

    Transfer learning starts from a model pretrained on a large dataset and adapts it to your task, instead of training from scratch. You can freeze the pretrained layers and train a new head, or fine-tune some or all layers with a small learning rate. Use it whenever data is limited and a related pretrained model exists.

    The explanation

    The early layers of a vision model learn general features such as edges and textures that transfer to almost any images; later layers are more task-specific. With a few hundred labelled images you might freeze the backbone and train only a classifier; with tens of thousands you can fine-tune more layers.

    The same idea drives language models: a pretrained LLM fine-tuned or prompted for your task is transfer learning. Watch for domain mismatch, such as models pretrained on photos used for X-rays, and use the same preprocessing the pretrained model expects.

    An example you can use in the interview

    For classifying photos of crop diseases with only 2,000 labelled images, training a network from scratch overfitted. Starting from a model pretrained on ImageNet, I first trained only a new final layer, then fine-tuned the last few blocks with a small learning rate. Validation accuracy was far higher than from scratch, and training took under an hour.

    They may follow up with

    • How do you decide how many layers to unfreeze?
    • Why use a smaller learning rate when fine-tuning?

    Avoid

    • Using different input normalisation from the pretrained model
    • Fine-tuning everything at a high learning rate on tiny data

    Practice this oneLesson: CNNs for images

  21. 21Use casePro 1

    When would you serve predictions in batch, and when online?

    Short answer

    Batch scoring runs on a schedule over many records and stores the results, which is cheap and simple when predictions can be a few hours old, such as nightly churn scores. Online serving computes a prediction per request behind an API, needed when the answer depends on fresh input, such as fraud checks at payment time.

    The explanation

    Ask how fresh the prediction must be and how many entities there are. Recommendations for millions of users can be precomputed nightly; a search ranking that depends on the query cannot.

    Online serving needs a model server, features available at request time (often a feature store to keep training and serving features consistent), a latency budget, autoscaling and fallbacks. A common hybrid precomputes heavy features in batch and does a light model call online.

    An example you can use in the interview

    At a lending app, we scored every customer's risk of missing an EMI each night in batch, because collections teams plan calls in the morning and a day-old score is fine. But the fraud check on a new loan application ran online in under 200 milliseconds, because it depended on the device and details submitted at that moment.

    They may follow up with

    • What is training-serving skew, and how do you avoid it?
    • How would you add a fallback if the model server is down?

    Avoid

    • Choosing online serving when batch would do
    • Computing features differently in training and serving

    Practice this oneLesson: Serving a model

  22. 22ScenarioPro 1

    How do you detect and handle model drift in production?

    Short answer

    Monitor inputs and outputs, not just uptime. Data drift is when input distributions change; concept drift is when the relationship between inputs and the target changes. Track feature statistics, prediction distributions and, when labels arrive, real performance. Alert on meaningful shifts, investigate, and retrain or roll back with a tested pipeline.

    The explanation

    Labels often arrive late: you learn whether a loan defaulted months later. So use proxies in the meantime: compare live feature distributions with training data using measures such as population stability index or a statistical test, watch the share of each predicted class, and track business metrics.

    Not every shift needs retraining; a festival season can shift spending without breaking the model. Set thresholds with care to avoid alert fatigue, keep a reference dataset per model version, and make retraining a routine, versioned pipeline with evaluation gates rather than a manual scramble.

    An example you can use in the interview

    Our delivery-time model's errors grew during the monsoon. Feature monitoring showed the share of orders in rainy hours had jumped, which is data drift, and late-delivery labels showed the model underestimated rain delays more than before, which looked like concept drift. We alerted on the error trend, retrained with the last two monsoon seasons weighted more, tested on held-out recent weeks, and deployed with the old model ready for rollback.

    They may follow up with

    • What would you monitor when labels arrive months later?
    • When is retraining the wrong fix?

    Avoid

    • Monitoring only latency and errors
    • Retraining automatically without an evaluation gate

    Practice this oneLesson: Monitoring and drift

  23. 23ScenarioPro 1

    Your model scored well offline but performed badly after launch. What could explain it?

    Short answer

    Common causes: data leakage made offline scores too optimistic; training data does not match live data (skew); features are computed differently in production; the population changed (drift); or the offline metric does not reflect the business goal. I would compare feature distributions offline versus online, check for leakage, and replay live inputs through the training pipeline.

    The explanation

    A gap between offline and online results usually means the evaluation did not reflect reality. Leakage, such as a feature that is only known after the event, inflates offline scores. Training-serving skew happens when production code computes a feature differently, uses stale values or fills missing data another way.

    To diagnose, log production inputs and predictions, compare their distributions to training data, and recompute some live predictions offline to see if they match. Also check the metric: a model that improves AUC may not improve the decision the business makes. Fix the cause, then add monitoring so the gap is caught early.

    An example you can use in the interview

    A churn model I worked on had excellent validation scores but did not help the retention team at all. Comparing features, I found 'days since last complaint' was computed from a table that, in training, included complaints logged after the customer had already decided to leave, which was leakage. In production that information did not exist yet. Rebuilding the training set with point-in-time features dropped the offline score, but the new model's online results matched it, and the team could trust it.

    They may follow up with

    • How would you detect training-serving skew?
    • How would you set up an evaluation that predicts online results better?

    Avoid

    • Retraining immediately without diagnosing
    • Assuming it is drift without checking for leakage

    Practice this oneLesson: Monitoring and drift

  24. 24Use casePro 2

    Design a recommendation system for an Indian e-commerce app.

    Short answer

    Clarify the goal and constraints first: what to recommend, where, the metric (clicks, purchases, revenue), scale and latency. Then a two-stage design: candidate generation from collaborative filtering, item similarity and popular items in the user's region and language, then a ranking model on user, item and context features. Handle cold start, evaluate offline then with an A/B test, and monitor.

    The explanation

    Good answers think about data: views, carts, purchases and returns as implicit feedback; item text and images for new products; signals such as city, language and festival season. Candidate generation narrows millions of items to hundreds quickly, using embeddings and nearest-neighbour search. The ranker, often gradient boosting or a neural model, scores those with richer features.

    Cold start: new users get popular and regional items or ask a few preferences; new items lean on content embeddings. Offline metrics such as recall at k and NDCG guide development, but the A/B test on business metrics decides. Watch for feedback loops that only show popular items, and add diversity and business rules such as stock availability.

    An example you can use in the interview

    For a fashion app, I would aim at purchases per session. Candidate generation: items similar to what the user viewed, items bought together, and trending items in their city and language. A ranking model then scores those few hundred candidates on user history, price band, delivery time to their PIN code and freshness. New users get popular items for their region. I would test offline on past sessions, then run an A/B test.

    They may follow up with

    • How would you handle a brand new user?
    • Why might offline metrics disagree with the A/B test?

    Avoid

    • Jumping to a model before clarifying the goal
    • Ignoring cold start and evaluation

    Practice this oneLesson: ML interviews

  25. 25Real lifePro 1

    Walk me through an ML project you did, end to end.

    Short answer

    Cover the problem and the decision it supports, the data and how you cleaned it, the baseline, the features and models you tried, how you validated without leakage, the metric and why it fit, the result against the baseline, and how it was used. End with what you would improve, in about two minutes.

    The explanation

    Interviewers look for a full loop and for judgement at each step. Starting with the decision, for example 'which loans to send for manual review', shows you understand the business. A simple baseline shows discipline, and an honest comparison shows you can measure.

    Mention one hard problem you solved, such as imbalanced classes, missing values or leakage, because it gives the interviewer something to ask about. If the project never reached production, say how it would be served and monitored. Numbers should be ones you can explain.

    An example you can use in the interview

    For my final-year project I predicted which customers of a regional electricity distributor would pay late, using two years of anonymised billing data the utility shared with our college. The goal was to decide whom to remind early. The baseline was 'paid late last month', which caught about half the late payers. I cleaned meter gaps, built features like payment streaks and seasonal usage, and used time-based validation so the model never saw the future. Gradient boosting caught noticeably more late payers at the same number of reminders. We handed it over as a weekly batch score.

    They may follow up with

    • Why did you choose that metric?
    • What would you monitor in production?

    Avoid

    • Only listing algorithms tried
    • No baseline to compare against

    Practice this oneLesson: ML interviews

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.