Interview Q&A · questions with model answers
Machine Learning Fundamentals Interview Questions
Part of the study plan for: Machine Learning Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked What is the difference between supervised, unsupervised and reinforcement learning?
Supervised learning trains on labelled examples to predict a target (price, spam or not). Unsupervised learning finds structure in unlabelled data (clusters, lower-dimensional representations,…
-
Most asked Explain the bias-variance trade-off.
A model's error on new data comes from bias (too simple to capture the pattern: underfitting), variance (too sensitive to the training data: overfitting) and irreducible noise. Making a model more…
-
Most asked What is overfitting, and how do you prevent it?
Overfitting is when a model learns the noise and quirks of its training data instead of the general pattern, so it scores well in training but poorly on new data. Prevent it with more or better…
-
Most asked How do you split data for training, validation and testing, and what is cross-validation?
Train on one part, tune choices on a validation part, and report final performance once on a held-out test part. k-fold cross-validation rotates the validation fold through the training data so…
-
Most asked Which metrics would you use for a classification model, and when is accuracy misleading?
Accuracy misleads on imbalanced data: a fraud model that predicts "not fraud" every time is 99.9% accurate and useless. Use precision (of predicted positives, how many are right), recall (of real…
-
Most asked Compare decision trees, random forests and gradient boosting.
A decision tree splits data with if/else rules; it's interpretable but overfits easily. A random forest averages many deep trees trained on random samples and feature subsets, which reduces…
-
Most asked Your model scored well offline but performs badly in production. What do you check?
Compare what the model sees in production with what it saw in training. The usual causes are training-serving skew (features computed differently), data drift (the input distribution changed),…
-
Most asked Design a system that serves predictions from a trained model to a web application.
Package the model with its preprocessing as a versioned artifact, serve it behind an API (or batch-score into a table if predictions can be precomputed), fetch online features from a low-latency…
-
Most asked Write scikit-learn code that trains and evaluates a classifier without leaking preprocessing.
Put preprocessing and the model into one Pipeline (with a ColumnTransformer for numeric and categorical columns), split the data first, and evaluate with cross-validation on the training data and…
-
What is data leakage, and how do you detect it?
Leakage is information in the training data that wouldn't be available when the model makes real predictions, such as a feature computed after the outcome, or test data influencing preprocessing. It…
-
How do you handle imbalanced classes?
First pick metrics that reflect the imbalance (precision, recall, PR-AUC) and tune the decision threshold. Then, if needed, use class weights, resampling (undersample the majority, oversample or…
-
Explain gradient descent and the role of the learning rate.
Gradient descent minimises a loss by repeatedly moving the model's parameters a small step in the direction that reduces the loss fastest (the negative gradient). The learning rate sets the step…
-
What is regularisation, and how do L1 and L2 differ?
Regularisation adds a penalty on model complexity to the loss so the model prefers simpler solutions and overfits less. L2 (ridge) penalises squared weights and shrinks them all smoothly; L1 (lasso)…
-
How do you approach feature engineering for a tabular model?
Start from domain understanding and how the prediction will be used, then build features that are available at prediction time: cleaned numeric values, encoded categories, dates broken into useful…
-
What is the difference between parameters and hyperparameters, and how do you tune hyperparameters?
Parameters are learned from data during training (weights, split points). Hyperparameters are set before training and control how learning happens (learning rate, tree depth, regularisation…
-
What are data drift and concept drift, and how do you monitor for them?
Data drift (covariate shift) is a change in the input distribution, such as more mobile users or new products. Concept drift is a change in the relationship between inputs and the target, such as…
-
What is the difference between bagging and boosting?
Bagging trains many models independently on bootstrap samples and averages them, which mainly reduces variance (random forests). Boosting trains models sequentially, each focusing on the previous…
-
How does k-means clustering work, and how do you choose k?
k-means places k centroids, assigns each point to its nearest centroid, moves each centroid to the mean of its points, and repeats until assignments stop changing. Choose k with the elbow method…
-
What is dimensionality reduction, and when would you use PCA?
Dimensionality reduction represents data with fewer features while keeping most of the useful information. PCA finds new axes (principal components) along which the data varies most; you keep the…
-
Explain how a neural network learns with backpropagation.
A forward pass computes predictions layer by layer and a loss compares them with targets. Backpropagation applies the chain rule to compute the gradient of the loss with respect to every weight,…
-
When would you choose a simple model over a deep learning model?
Choose a simple model (linear or logistic regression, gradient-boosted trees) for tabular data, small datasets, strict latency or cost limits, or when you must explain decisions. Deep learning pays…
-
How do you explain a model's predictions to stakeholders?
Use global explanations for what the model relies on overall (permutation importance, SHAP summary plots, partial dependence) and local explanations for single predictions (SHAP values per feature).…
-
How would you design an A/B test to decide whether a new model should replace the old one?
Define a primary business metric and guardrail metrics, randomise users (not requests) into control and treatment, size the test with a power calculation for the smallest effect worth detecting, run…
-
What is MLOps, and what does a production ML pipeline include?
MLOps applies DevOps practices to machine learning: reproducible data and training pipelines, versioned models with lineage, automated testing and deployment, and monitoring and retraining in…
-
How do you check a model for unfair bias?
Measure performance and outcomes separately for relevant groups (where you can lawfully use the attributes): error rates, approval rates, calibration. Compare them against fairness criteria suited…
-
What is the difference between online and batch inference, and how do you choose?
Batch inference scores many records on a schedule and stores the results (nightly churn scores); online inference scores each request in real time behind an API (fraud check at checkout). Choose…