Menu
CareerGuide 23 of 36

Career guide · Guide 23 of 36

Top 50 Machine Learning Interview Questions and Answers

Top 50 machine learning interview questions with simple answers for freshers and experienced: algorithms, metrics, overfitting, feature engineering and MLOps.

  • Intermediate
  • 29 min read
  • Updated Nov 2026
On this page
  1. Question list
  2. Beginner machine learning interview questions (freshers)
  3. Intermediate machine learning interview questions
  4. Advanced machine learning interview questions (experienced)
  5. How to prepare

These 50 questions cover what machine learning interviews ask data scientists and ML engineers, from freshers to experienced candidates: the basics, the main algorithms, evaluation metrics, overfitting and the bias-variance trade-off, feature engineering, and putting models into production. Each answer is written in plain words and gets straight to the point. If you are unsure how ML relates to deep learning and AI, start with AI vs machine learning vs deep learning.

Question list

Show all 50 questions
  1. What is machine learning?
  2. What is the difference between supervised, unsupervised and reinforcement learning?
  3. What is the difference between classification and regression?
  4. What are training, validation and test sets?
  5. What is overfitting vs underfitting, and how do you fix each?
  6. What is the bias-variance trade-off?
  7. What is cross-validation?
  8. What is feature engineering?
  9. How do you handle categorical variables?
  10. How does linear regression work?
  11. How does logistic regression work?
  12. How does a decision tree work?
  13. What is the difference between precision and recall?
  14. What is a confusion matrix?
  15. Why can accuracy be misleading?
  16. What is ROC AUC, and when should you use PR AUC instead?
  17. What is the F1 score?
  18. How do you handle imbalanced data?
  19. What is regularisation, and what is the difference between L1 and L2?
  20. How does random forest work?
  21. How does gradient boosting work?
  22. Bagging vs boosting: what is the difference?
  23. How does k-means clustering work?
  24. What is PCA?
  25. What is k-nearest neighbours (KNN)?
  26. What is feature scaling, and when is it needed?
  27. What is data leakage?
  28. What are hyperparameters, and how do you tune them?
  29. What is gradient descent?
  30. How does a support vector machine (SVM) work?
  31. How do you choose an algorithm for a problem?
  32. What is the difference between a parametric and a non-parametric model?
  33. What is naive Bayes?
  34. What is model interpretability, and how do you explain a model’s predictions?
  35. How do you handle missing values for a machine learning model?
  36. What is the curse of dimensionality?
  37. How would you build a churn prediction model end to end?
  38. How do you deploy and monitor a machine learning model?
  39. What is data drift vs concept drift?
  40. How do you validate a time-series model?
  41. How do you choose a classification threshold?
  42. What is model calibration?
  43. How does XGBoost differ from a basic gradient boosting implementation?
  44. How do you design an A/B test for a new model?
  45. What are the common pitfalls when moving a model from notebook to production?
  46. How do you explain a complex model’s decision to a regulator or customer?
  47. How do you check a model for fairness?
  48. Batch vs online (real-time) prediction: how do you choose?
  49. What is stacking?
  50. Tell me about a machine learning project you worked on.

Beginner machine learning interview questions (freshers)

1. What is machine learning?

Beginner · Very Common · Basics

Machine learning is a way of building software that learns patterns from data instead of following rules written by hand. You give an algorithm examples, such as past loans with whether they were repaid, and it learns a model that makes predictions on new data, such as the risk of a new loan. The model improves as it sees more and better data. It is the main technique behind most modern AI.

Learn more: The Machine Learning Workflow: From Data to a Working Model

2. What is the difference between supervised, unsupervised and reinforcement learning?

Beginner · Very Common · Basics

In supervised learning, training data has the correct answer (a label) for each example, and the model learns to predict it: spam or not spam, house price. In unsupervised learning there are no labels, and the model finds structure, such as customer groups (clustering) or unusual records. In reinforcement learning, an agent learns by trial and error, taking actions and receiving rewards, as in game playing or robot control.

Most business problems are supervised, because companies usually have historical outcomes to learn from. A good interview example for each: predicting loan default (supervised), segmenting customers for marketing (unsupervised), and optimising a recommendation strategy from user clicks over time (reinforcement learning).

Learn more: The Machine Learning Workflow: From Data to a Working Model

3. What is the difference between classification and regression?

Beginner · Very Common · Basics

Both are supervised learning. Classification predicts a category: will this customer churn (yes or no), which digit is in this image. Regression predicts a number: next month’s sales, a house price. Some algorithms, such as decision trees and neural networks, can do both. Logistic regression, despite its name, is a classification method because it predicts the probability of a class.

The choice also decides the metrics. Classification uses accuracy, precision, recall, F1 and ROC AUC; regression uses mean absolute error, root mean squared error or R-squared. Some problems can be framed either way: predicting a customer’s spend (regression) or whether they will spend more than 100 (classification). Choose the framing that matches the decision the business will make.

Learn more: The Machine Learning Workflow: From Data to a Working Model

4. What are training, validation and test sets?

Beginner · Very Common · Evaluation

The training set is used to fit the model. The validation set is used to compare models and tune settings such as hyperparameters. The test set is kept aside until the very end and used once to estimate how the final model performs on new data. Keeping them separate prevents an overly optimistic score. A common split is 70/15/15, and for time-based data the split should follow time order.

If you tune your model many times against the test set, it stops being a fair test, because you have indirectly fitted to it. That is why the test set is used once, at the end.

5. What is overfitting vs underfitting, and how do you fix each?

Beginner · Very Common · Evaluation

Overfitting is when a model learns the training data too closely, including its noise, so it scores well on training data but poorly on new data. Underfitting is the opposite: the model is too simple to capture the real pattern, so it does badly on both training and new data.

Compare training and validation error to tell them apart:

  • Underfitting: both errors are high and close together (high bias).
  • Overfitting: training error is low but validation error is much higher (high variance).

Fixes for overfitting: more data, a simpler model or fewer features, regularisation (L1, L2, dropout), limiting tree depth, early stopping, and cross-validation to choose settings. Also check for data leakage, where information the model would not have at prediction time slips into the features.

Fixes for underfitting: a more flexible model, better or additional features, less regularisation, and longer training for neural networks and boosted trees.

For example, fitting a straight line to a curved relationship underfits, while a very high-degree polynomial passes near every training point but swings wildly on new data.

Learn more: Overfitting vs Underfitting: How to Spot and Fix Each

6. What is the bias-variance trade-off?

Beginner · Very Common · Theory

Bias is error from a model being too simple, so it misses real patterns (underfitting). Variance is error from a model being too sensitive to the particular training data, so it changes a lot with small data changes (overfitting). Making a model more complex usually lowers bias but raises variance. The goal is the balance that gives the lowest error on new data, found with validation and cross-validation.

A practical way to diagnose it: if training and validation errors are both high, you have high bias, so add features or use a more flexible model. If training error is low but validation error is much higher, you have high variance, so add data, simplify the model or regularise it.

Learn more: Overfitting, Cross-Validation and Data Leakage

7. What is cross-validation?

Beginner · Very Common · Evaluation

Cross-validation estimates how well a model will perform on new data by training and testing it several times on different splits. In k-fold cross-validation, the data is split into k parts; the model trains on k-1 parts and is tested on the remaining one, k times, and the scores are averaged. It gives a more reliable estimate than one split, especially with small datasets. For time series, use time-ordered splits instead.

Learn more: Overfitting, Cross-Validation and Data Leakage

8. What is feature engineering?

Beginner · Very Common · Features

Feature engineering is creating input variables that help a model learn. Examples: turning a date into day of week and month, computing a customer’s average spend over 90 days, counting failed logins in the last hour, or taking the log of a skewed value. Good features often improve a model more than a better algorithm. They must use only information available at prediction time, or the model will leak the answer.

9. How do you handle categorical variables?

Beginner · Common · Features

Models need numbers, so categories must be encoded. One-hot encoding creates a 0/1 column per category, which suits few categories. Ordinal encoding maps ordered categories to numbers, such as small = 1, medium = 2. For many categories, use target encoding (the average target per category, computed carefully to avoid leakage), frequency encoding, or embeddings. Tree-based libraries such as LightGBM and CatBoost can also handle categories directly.

Be careful with one-hot encoding on columns with thousands of values, such as city or product ID: it creates a huge, sparse table and can cause overfitting. Group rare categories into an “other” bucket first, and make sure the encoder handles categories that appear only in new data.

10. How does linear regression work?

Beginner · Very Common · Algorithms

Linear regression predicts a number as a weighted sum of input features plus a constant: price = b0 + b1 x area + b2 x rooms. It finds the weights that minimise the sum of squared differences between predictions and actual values. It is fast and easy to explain, since each weight shows a feature’s effect. It assumes a roughly linear relationship, and is sensitive to outliers and strongly correlated features.

Learn more: Linear and Logistic Regression Explained, with Python

11. How does logistic regression work?

Beginner · Very Common · Algorithms

Logistic regression predicts the probability of a class. It calculates a weighted sum of features, like linear regression, then passes it through the sigmoid function, which squeezes any number into a value between 0 and 1. Weights are learned by minimising log loss. You choose a threshold, such as 0.5, to turn probabilities into classes. It is fast, interpretable and a strong baseline for classification.

Each weight has a clear meaning: it changes the log-odds of the outcome for a one-unit change in the feature, which makes the model easy to explain to business users and regulators. Scale features and use regularisation when there are many of them.

Learn more: Linear and Logistic Regression Explained, with Python

12. How does a decision tree work?

Beginner · Very Common · Algorithms

A decision tree splits the data step by step using questions on features, such as “income above 50,000?”, choosing at each step the split that best separates the target, measured by Gini impurity or entropy for classification, or variance for regression. Each leaf gives a prediction. Trees are easy to explain and handle mixed data types, but a single deep tree overfits easily, so they are usually limited in depth or combined in ensembles.

Learn more: Decision Trees, Random Forests and Gradient Boosting

13. What is the difference between precision and recall?

Beginner · Very Common · Metrics

Precision is the share of predicted positives that are truly positive: of the transactions flagged as fraud, how many were fraud. Recall is the share of actual positives the model found: of all fraud, how much was flagged. Increasing the threshold usually raises precision and lowers recall. Choose based on cost: for cancer screening, recall matters most; for a spam filter that hides email, precision matters most.

A simple way to remember them: precision asks “when the model says yes, how often is it right?”; recall asks “of all the real yes cases, how many did the model catch?”.

Learn more: Evaluation Metrics: Precision, Recall, ROC AUC and Thresholds

14. What is a confusion matrix?

Beginner · Common · Metrics

A confusion matrix is a table that compares predicted classes with actual classes. For two classes it has four cells: true positives, false positives, true negatives and false negatives. Accuracy, precision, recall, specificity and the F1 score are all calculated from it. It shows exactly which kinds of mistakes a model makes, which a single accuracy number hides.

For example, in a fraud model tested on 1,000 transactions with 20 frauds: 15 true positives (fraud caught), 5 false negatives (fraud missed), 30 false positives (good transactions flagged) and 950 true negatives. Precision is 15/45 = 33% and recall is 15/20 = 75%, which says much more than the 96.5% accuracy.

Learn more: Evaluation Metrics: Precision, Recall, ROC AUC and Thresholds

15. Why can accuracy be misleading?

Beginner · Very Common · Metrics

Accuracy is the share of all predictions that are correct, but with imbalanced classes it can look excellent while the model is useless. If 1% of transactions are fraud, a model that always says “not fraud” is 99% accurate and catches no fraud at all. For imbalanced problems, use precision, recall, F1, the precision-recall curve or ROC AUC, and look at the confusion matrix.

Accuracy is fine when classes are roughly balanced and both kinds of mistakes cost about the same. In interviews, always ask how balanced the classes are before naming a metric.

Learn more: Evaluation Metrics: Precision, Recall, ROC AUC and Thresholds

Intermediate machine learning interview questions

16. What is ROC AUC, and when should you use PR AUC instead?

Intermediate · Very Common · Metrics

The ROC curve plots the true positive rate (recall) against the false positive rate at every classification threshold. ROC AUC, the area under it, is the probability that the model scores a random positive example above a random negative one: 0.5 is random guessing and 1.0 is perfect ranking. It does not depend on choosing a threshold, which makes it handy for comparing models.

PR AUC is the area under the precision-recall curve. Its random baseline is the share of positives, for example about 0.01 when 1% of transactions are fraud.

Use PR AUC when positives are rare and false alarms are costly. ROC AUC can look high on imbalanced data because the false positive rate divides by the huge number of negatives, so thousands of false alarms still look like a small rate. Precision shows how many alerts are real. A fraud model can have a ROC AUC of 0.90 and a PR AUC of only 0.05, which means most alerts at a useful recall are false alarms.

For balanced classes, ROC AUC is fine. In both cases, finish by choosing a threshold and reporting precision and recall at that threshold, because that is what the business will experience.

Learn more: ROC AUC vs PR AUC: Which Metric to Use for Imbalanced Data

17. What is the F1 score?

Intermediate · Common · Metrics

The F1 score is the harmonic mean of precision and recall: 2 x precision x recall / (precision + recall). It is high only when both are reasonably high, so it is useful when you need a single number that balances false positives and false negatives, especially with imbalanced classes. If one type of error is more costly, use a weighted version (F-beta) or choose the threshold directly from business costs.

Learn more: Evaluation Metrics: Precision, Recall, ROC AUC and Thresholds

18. How do you handle imbalanced data?

Intermediate · Very Common · Data

First use suitable metrics such as precision, recall and the precision-recall curve, not accuracy. Then options include: class weights so mistakes on the rare class cost more, resampling (oversampling the rare class, for example with SMOTE, or undersampling the common class), choosing a decision threshold based on business costs, and collecting more examples of the rare class. Always resample only the training data, never the test data.

Also check whether the imbalance is real or a sampling artefact. And remember that after resampling or class weighting, predicted probabilities no longer match real-world rates, so recalibrate them if they are used directly.

19. What is regularisation, and what is the difference between L1 and L2?

Intermediate · Very Common · Theory

Regularisation adds a penalty for large model weights to the training objective, which discourages overfitting. L1 (lasso) adds the sum of absolute weights; it pushes some weights to exactly zero, so it also selects features. L2 (ridge) adds the sum of squared weights; it shrinks all weights smoothly but rarely to zero, and handles correlated features well. Elastic net combines both. The penalty strength is a hyperparameter tuned with validation.

Learn more: Overfitting, Cross-Validation and Data Leakage

20. How does random forest work?

Intermediate · Very Common · Algorithms

A random forest trains many decision trees, each on a random sample of the rows (bootstrap sampling) and considering a random subset of features at each split. Each tree overfits a little differently, and averaging their predictions (or voting, for classification) cancels much of that out, giving a model that is accurate, stable and hard to overfit. It needs little tuning and gives feature importance scores.

The two most important settings are the number of trees (more is rarely worse, just slower) and the number of features considered at each split. Its built-in feature importance can be biased towards features with many unique values, so permutation importance is a safer check.

Learn more: Decision Trees, Random Forests and Gradient Boosting

21. How does gradient boosting work?

Intermediate · Very Common · Algorithms

Gradient boosting builds trees one after another, where each new small tree is trained to correct the errors (the gradient of the loss) of the trees so far. Predictions are the sum of all trees, scaled by a learning rate. It is often the most accurate method for tabular data. Popular implementations are XGBoost, LightGBM and CatBoost. It needs more tuning than random forest: learning rate, number of trees, tree depth and early stopping.

Learn more: Decision Trees, Random Forests and Gradient Boosting

22. Bagging vs boosting: what is the difference?

Intermediate · Very Common · Algorithms

Both combine many models, usually trees. Bagging trains models independently and in parallel on random samples of the data, then averages them; it mainly reduces variance (random forest is the classic example). Boosting trains models in sequence, each one focusing on the previous models’ errors; it mainly reduces bias and is often more accurate, but is more sensitive to noisy data and overfitting if not tuned.

In practice: start with random forest when you want a strong model with little tuning, and use gradient boosting (XGBoost, LightGBM, CatBoost) when you want the best accuracy on tabular data and can spend time on tuning and early stopping.

Learn more: Decision Trees, Random Forests and Gradient Boosting

23. How does k-means clustering work?

Intermediate · Very Common · Algorithms

K-means groups data into k clusters. It picks k starting centres, assigns each point to the nearest centre, moves each centre to the average of its points, and repeats until assignments stop changing. Choose k with the elbow method or silhouette score, and scale features first, because it uses distances. It assumes roughly round, similar-sized clusters and is sensitive to the starting centres, so run it several times.

For clusters with odd shapes or lots of noise, DBSCAN or hierarchical clustering can work better. And remember that clusters are only useful if the business can describe and act on them, so always profile each cluster with simple statistics.

24. What is PCA?

Intermediate · Common · Algorithms

Principal component analysis reduces the number of features by finding new axes, called principal components, that capture the most variance in the data. The first component captures the most, the second the most of what is left, and so on, and they are uncorrelated. Keeping the first few components compresses the data, speeds up models and helps visualisation. Features must be scaled first, and the components are harder to interpret than the original features.

25. What is k-nearest neighbours (KNN)?

Intermediate · Common · Algorithms

KNN predicts for a new point by looking at the k most similar points in the training data and taking a majority vote (classification) or an average (regression). It learns nothing in advance, so training is instant but predictions are slow on large datasets. Results depend heavily on the choice of k, the distance measure and feature scaling, and it works poorly with many features.

KNN is a useful baseline and the idea behind similarity search: recommendation and vector search systems use approximate nearest-neighbour methods to find similar items quickly in very large datasets.

26. What is feature scaling, and when is it needed?

Intermediate · Common · Features

Feature scaling puts numeric features on comparable ranges. Standardisation subtracts the mean and divides by the standard deviation; min-max scaling maps values to between 0 and 1. It is needed for methods based on distances or gradients: KNN, k-means, SVM, PCA, linear models with regularisation and neural networks. Tree-based models do not need it. Fit the scaler on training data only, then apply it to validation and test data.

If you fit the scaler on all the data before splitting, information from the test set leaks into training. Putting the scaler and the model in one pipeline, such as a scikit-learn Pipeline, avoids this automatically.

27. What is data leakage?

Intermediate · Very Common · Evaluation

Data leakage is when information that would not be available at prediction time gets into training, so the model looks better in testing than it will in real use. Examples: a feature recorded after the outcome, such as “refund issued” when predicting fraud; scaling or encoding fitted on the whole dataset; random splits on time-series data; or duplicate customers in both training and test. Prevent it with careful feature timing and pipelines fitted on training data only.

Learn more: Overfitting, Cross-Validation and Data Leakage

28. What are hyperparameters, and how do you tune them?

Intermediate · Very Common · Training

Hyperparameters are settings chosen before training, not learned from data: tree depth, learning rate, number of trees, regularisation strength. Tune them by trying combinations and comparing validation or cross-validation scores. Grid search tries every combination; random search samples combinations and is usually more efficient; Bayesian optimisation tools choose the next try based on earlier results. Keep the test set out of tuning.

Tune the few hyperparameters that matter most first, such as learning rate and tree depth for boosting, and use early stopping to choose the number of trees. Record every run with its settings and scores, so results are reproducible.

29. What is gradient descent?

Intermediate · Very Common · Training

Gradient descent is the method used to train many models, including neural networks. It starts with some weights, calculates how the loss changes with each weight (the gradient), and moves the weights a small step in the direction that lowers the loss, repeating many times. The step size is the learning rate: too large and training diverges, too small and it is slow. Stochastic and mini-batch versions use small samples of data for each step.

Learn more: How Neural Networks Learn: Loss, Gradient Descent and Backpropagation

30. How does a support vector machine (SVM) work?

Intermediate · Common · Algorithms

An SVM finds the boundary between classes that leaves the widest possible margin to the nearest points of each class, called support vectors. A soft margin allows some mistakes, controlled by the C parameter. With kernels, such as the RBF kernel, it can learn non-linear boundaries by working in a higher-dimensional space without computing it directly. SVMs work well on medium-sized data with many features, but scale poorly to very large datasets.

31. How do you choose an algorithm for a problem?

Intermediate · Common · Practice

Start from the problem and data: classification or regression, size of the data, structured or unstructured, need for explanations, and speed limits. For tabular data, start with a simple baseline such as logistic or linear regression, then try gradient boosting. For images, text and audio, use pre-trained deep learning models. Compare candidates with cross-validation on the same metric, and choose the simplest model that meets the requirement.

Also consider operational constraints early: a model that must explain each decision, run in a few milliseconds or be retrained daily may rule out some options even if they score slightly higher.

32. What is the difference between a parametric and a non-parametric model?

Intermediate · Common · Theory

A parametric model has a fixed number of parameters that summarise the data, whatever its size, such as linear or logistic regression. It is fast and needs less data, but makes strong assumptions about the shape of the relationship. A non-parametric model, such as KNN or a decision tree, grows in complexity with the data and makes fewer assumptions, which makes it more flexible but needs more data and can overfit.

33. What is naive Bayes?

Intermediate · Common · Algorithms

Naive Bayes is a classifier based on Bayes’ theorem. It calculates the probability of each class given the features, assuming the features are independent of each other given the class, which is the “naive” part. Despite that simplification, it works well for text classification such as spam filtering, is very fast to train, and needs little data. Its probability estimates are often poorly calibrated, even when its rankings are good.

34. What is model interpretability, and how do you explain a model’s predictions?

Intermediate · Common · Practice

Interpretability means understanding why a model makes its predictions. Simple models can be read directly: coefficients in linear models, rules in small trees. For complex models, use feature importance, permutation importance, partial dependence plots, and SHAP values, which show how much each feature pushed a single prediction up or down. Explanations help debugging, build trust and are sometimes required by regulation, as in lending.

Be careful with interpretation: feature importance shows what the model uses, not what causes the outcome in the real world. Correlated features can also share or swap importance, so check explanations with domain experts.

35. How do you handle missing values for a machine learning model?

Intermediate · Common · Data

First understand why values are missing, because missingness itself can carry information. Options: drop rows or columns when few values are missing and it is random; impute with the median, the most frequent value or a model-based estimate; and add a 0/1 indicator column showing that the value was missing. Some algorithms, such as XGBoost and LightGBM, handle missing values natively. Fit any imputation on training data only.

Whatever you choose, apply exactly the same imputation at prediction time, by saving it in the same pipeline as the model.

36. What is the curse of dimensionality?

Intermediate · Common · Theory

As the number of features grows, the space becomes so large that data points become sparse and far apart, and distances between points become similar. Models then need far more data to find reliable patterns, distance-based methods such as KNN and k-means work poorly, and overfitting becomes more likely. Remedies include feature selection, dimensionality reduction such as PCA, regularisation and collecting more data.

A common example: one-hot encoding many high-cardinality columns can create thousands of sparse features, which makes distance-based models fail and linear models overfit unless they are regularised.

Advanced machine learning interview questions (experienced)

37. How would you build a churn prediction model end to end?

Advanced · Very Common · Case

Define churn precisely (no purchase in 60 days, say) and the prediction point and horizon. Build a training table with one row per customer per snapshot date, using only data available at that date: recency, frequency, spend, support tickets, usage trends. Split by time, train a baseline and a gradient boosting model, and evaluate with precision and recall at the top of the ranking. Decide how the scores will be used, such as a retention offer, and measure the effect with an experiment.

38. How do you deploy and monitor a machine learning model?

Advanced · Very Common · MLOps

Package the model with its preprocessing in one pipeline, version it in a model registry with its data and code versions, and serve it as a batch job or an online API. Monitor input data drift (feature distributions changing), prediction drift, data quality, latency and errors, and model performance once true labels arrive. Set alerts and a retraining process, and roll out new versions gradually with the option to roll back.

Learn more: Model Monitoring and Data Drift: Keeping Models Healthy

39. What is data drift vs concept drift?

Advanced · Common · MLOps

Data drift is when the distribution of input features changes, such as more young customers than before, even if the relationship to the target is the same. Concept drift is when the relationship itself changes, such as fraudsters changing tactics so the same features now mean something different. Both reduce performance. Detect data drift with statistical comparisons of feature distributions, and concept drift by tracking performance on fresh labels.

Common tools for comparing distributions are the population stability index (PSI) and statistical tests such as Kolmogorov-Smirnov. Not every drift needs action: alert on drift in important features, then check whether performance actually dropped before retraining.

Learn more: Model Monitoring and Data Drift: Keeping Models Healthy

40. How do you validate a time-series model?

Advanced · Common · Evaluation

Never shuffle time-series data. Use time-ordered splits: train on the past and test on the future, ideally with rolling or expanding windows that repeat this several times (backtesting). Make sure features use only information available at each forecast time, including lags and rolling averages. Compare against simple baselines, such as last value or same period last year, which are surprisingly hard to beat.

Also leave a gap between training and test periods when labels take time to become known, such as churn defined over the next 60 days, so the training labels do not overlap the test period.

41. How do you choose a classification threshold?

Advanced · Common · Practice

The default 0.5 is rarely right. Choose the threshold from the business trade-off. Estimate the cost of a false positive and of a false negative, then pick the threshold that gives the lowest total cost on validation data. Or pick the one that meets a constraint, such as “review at most 500 cases a day” or “recall at least 90%”. Check that predicted probabilities are calibrated if you use them directly.

For example, if a missed fraud costs 500 and a false alarm costs 5 in review time, the best threshold is much lower than 0.5, because missing fraud is 100 times more expensive than a false alarm.

Learn more: Evaluation Metrics: Precision, Recall, ROC AUC and Thresholds

42. What is model calibration?

Advanced · Common · Evaluation

A model is calibrated when its predicted probabilities match real frequencies: of all cases given 0.8, about 80% should be positive. Many models, such as boosted trees and naive Bayes, rank well but give poorly calibrated probabilities. Check with a reliability curve or the Brier score, and fix with Platt scaling or isotonic regression on a held-out set. Calibration matters whenever probabilities feed decisions or expected-value calculations.

Fit the calibration on data the model was not trained on, such as a validation set or with cross-validation, otherwise the calibration itself overfits.

Learn more: Evaluation Metrics: Precision, Recall, ROC AUC and Thresholds

43. How does XGBoost differ from a basic gradient boosting implementation?

Advanced · Common · Algorithms

XGBoost adds regularisation of tree complexity to the objective, uses second-order gradient information for better splits, handles missing values by learning a default direction at each split, supports subsampling of rows and columns, and is engineered for speed with parallel and histogram-based split finding. Together these make it fast, accurate and resistant to overfitting, which is why it became a standard for tabular data.

LightGBM and CatBoost are popular alternatives: LightGBM is often faster on large data thanks to leaf-wise tree growth and histogram tricks, and CatBoost handles categorical features well with little preprocessing. In interviews, it is enough to know the general ideas and when you would try each.

Learn more: Decision Trees, Random Forests and Gradient Boosting

44. How do you design an A/B test for a new model?

Advanced · Common · Experimentation

Define the primary business metric, such as conversion or revenue per user, plus guardrail metrics. Randomly split users between the current model and the new one, calculate the sample size needed to detect the expected effect, and run for full business cycles. Check that groups are balanced, avoid stopping early, and analyse with a pre-planned statistical test. Offline metrics alone do not prove business impact.

If an online test is not possible, a shadow deployment, where the new model scores live traffic without affecting decisions, at least shows how it behaves on real data before launch.

Learn more: A/B Testing: Design, Sample Size and Analysis

45. What are the common pitfalls when moving a model from notebook to production?

Advanced · Common · MLOps

Training and serving features computed differently (training-serving skew), dependencies not pinned, preprocessing not saved with the model, data at prediction time missing or delayed, no monitoring, and no plan for retraining. Also, the model may be too slow or too large for the latency budget. Use shared feature code or a feature store, one pipeline object for preprocessing and model, tests, and a staged rollout.

A good habit is to turn the notebook into a tested training pipeline early, with fixed random seeds and logged data versions, so any model can be rebuilt exactly.

46. How do you explain a complex model’s decision to a regulator or customer?

Advanced · Common · Practice

Use explanations at two levels. Globally, show which features matter most and how they affect predictions, with partial dependence or SHAP summary plots. For a single decision, show the main reasons, such as “high credit utilisation and recent missed payments”, from SHAP values or reason codes. Document the data, model, validation and fairness checks. Where explanations must be exact, a simpler, interpretable model may be the better choice.

Explanations must also be consistent and understandable: test them with non-technical colleagues, and avoid technical terms in customer-facing reasons.

47. How do you check a model for fairness?

Advanced · Common · Ethics

Decide which groups and which fairness definition matter for the use case, then compare model performance and outcomes across groups: error rates, approval rates, precision and recall. Look for features that act as proxies for protected attributes. If gaps exist, fix the data, adjust features or thresholds, or use fairness-aware training, and document the trade-offs. Fairness checks should be repeated as data changes.

Note that different fairness definitions, such as equal approval rates and equal error rates, often cannot all be satisfied at once, so the choice must be made with legal, business and ethics input, not by the data scientist alone.

48. Batch vs online (real-time) prediction: how do you choose?

Advanced · Common · MLOps

Batch prediction scores many records on a schedule, such as nightly churn scores written to a table; it is simple, cheap and easy to monitor. Online prediction scores one request at a time through an API within milliseconds, such as fraud checks at payment time; it needs low-latency feature lookups and more operational work. Choose batch unless the decision must use information from the last few seconds or minutes.

A common middle ground is to precompute scores in batch and serve them from a fast key-value store, refreshing them every few minutes or hours, which gives fast responses without full online feature computation.

Learn more: Model Serving: Batch vs Online Predictions

49. What is stacking?

Advanced · Common · Algorithms

Stacking is an ensemble method that combines different kinds of models, such as a logistic regression, a random forest and a gradient boosting model, by training a final meta-model on their predictions. The base models’ predictions must be produced out-of-fold, with cross-validation, so the meta-model does not learn from leaked training predictions. It can add a little accuracy in competitions, but adds complexity, so it is used less in production.

50. Tell me about a machine learning project you worked on.

Advanced · Very Common · Behavioural

Structure it clearly:

  1. The business problem and how success was measured.
  2. The data and its problems.
  3. Your baseline, then the features and models you tried, and why.
  4. How you evaluated them, with numbers.
  5. How the model was used, and its impact, such as cost saved or revenue gained. Mention one mistake or surprise and what you learned. Interviewers look for judgement and impact, not just algorithms.

Prepare a two-minute version and a ten-minute version of the same story, because interviewers often ask for more detail on one part, such as how you handled leakage or why you chose the metric.

How to prepare

  1. Explain each core algorithm simply: linear and logistic regression, decision trees, random forest, gradient boosting, k-means and PCA. Say how it works, when to use it and its main weakness.
  2. Know your metrics: precision, recall, F1, ROC AUC and the confusion matrix, and when accuracy misleads.
  3. Practise one end-to-end project out loud: problem, data, features, baseline, model choice, evaluation and impact.
  4. Prepare for production questions: leakage, drift, monitoring and A/B tests separate experienced candidates.
  5. Revise statistics: probability, distributions, hypothesis tests and confidence intervals often come up in the same interview.

By , Data Engineer and Founder of DataDank · Last reviewed Oct 2026 · Core machine learning concepts as asked in data scientist and ML engineer interviews in 2026. Library names refer to current scikit-learn, XGBoost, LightGBM and CatBoost.

Search
Filter by type