Machine Learning Interview Questions for 7 Years Experience
40 questions with answers for candidates with 7 years of experience — 1 easy, 19 medium, 20 hard.
What interviewers expect: 7 years experience
Seven-year candidates are usually considered for lead or staff roles. Interviewers focus on strategy and leadership: building an ML roadmap, setting evaluation standards, managing stakeholders, handling failed projects and balancing research with delivery. Technical depth is still tested through design discussions on large-scale data, model risk and platform choices. Expect panel discussions.
This set is weighted towards Clustering and Dimensionality Reduction (9), Decision Trees and Ensembles (8), MLOps and Deployment (7), Classification Models (6).
ML roadmap and strategy Team leadership Model governance Platform decisions
Solved at this levelStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
✓ 3 questions free • Unlock the rest in seconds
01
How do one-vs-rest and multinomial approaches differ for multiclass classification?
One-vs-rest trains one binary classifier per class against all others and picks the highest score; it is simple but probabilities may not sum to one. Multinomial (softmax) logistic regression models all classes jointly with a single loss, giving consistent probabilities. For metrics, use macro averaging to treat classes equally or weighted averaging to account for class frequency.
02
What is the difference between batch, stochastic and mini-batch gradient descent?
Batch gradient descent uses the full dataset for each update, giving stable but slow and memory-heavy steps. Stochastic gradient descent updates after every single example, which is fast and noisy and can escape shallow minima. Mini-batch uses small groups such as 32 to 512 rows, balancing stability with speed and allowing vectorised computation. Mini-batch is the default in practice.
03
Compute permutation importance on validation data.
from sklearn.inspection import permutation_importance
import pandas as pd
r = permutation_importance(model, X_val, y_val, n_repeats=10,
scoring='roc_auc', random_state=42, n_jobs=-1)
imp = pd.Series(r.importances_mean, index=X_val.columns)
print(imp.sort_values(ascending=False))
Near-zero or negative values mean the feature adds little on unseen data.
Fix random seeds in NumPy, Python and the model, pin library versions in requirements.txt, version the data or record its hash, and save the exact code commit and hyperparameters. Tools like MLflow log parameters, metrics and artifacts per run. Use pipelines so preprocessing is identical each time, and keep the train-test split stored rather than recreated randomly.
05
What is the ROC curve and AUC? When is PR-AUC better?
The ROC curve plots true positive rate against false positive rate at every threshold, and AUC is the probability that a random positive is ranked above a random negative. It is threshold-independent. On heavily imbalanced data, like 0.5 percent fraud, ROC-AUC can look high even when precision is poor, so the precision-recall curve and PR-AUC give a more honest picture.
06
Your manager asks for a single number showing the model's business value. What do you give?
I would convert model outcomes into money or time using a cost matrix agreed with the business, for example savings from caught fraud minus the cost of reviewing false alerts. I would compare this against the current process or a rule-based baseline on holdout data and show a range rather than one point. A short note on assumptions keeps the number honest.
07
You need to detect unusual transactions but have no fraud labels. What do you do?
I would start with unsupervised anomaly detection: Isolation Forest or Local Outlier Factor on features like amount relative to the customer's usual spend, time of day, new device and merchant risk. I would set the threshold based on what the review team can handle, collect investigator feedback as labels, and move to a supervised model once enough labelled cases exist.
08
Labels for your loan model arrive only after 6 months. How do you monitor it meanwhile?
I would rely on proxy signals: input data drift with PSI, prediction score distribution, approval rates by segment, and early indicators like first missed payment at 30 or 60 days. Once enough early outcomes arrive, I would check performance on these. I would also set up a delayed evaluation job that computes full metrics as labels mature and compares them with the validation baseline.
09
What is the difference between PCA and t-SNE or UMAP?
PCA is a linear method that preserves global variance, is fast, deterministic and can transform new data, so it is used for preprocessing. t-SNE and UMAP are non-linear methods that preserve local neighbourhoods, producing good 2D visualisations of clusters. t-SNE distances between clusters are not meaningful. UMAP is faster, keeps more global structure and can transform new points.
10
How do you evaluate clustering when there are no labels?
Use internal metrics: silhouette score, Davies-Bouldin index (lower is better) and Calinski-Harabasz index (higher is better). Check stability by re-clustering on bootstrap samples. Most important is external usefulness: profile each cluster with key statistics and check whether business teams find the segments distinct and actionable, for example different response to a campaign.
Bias is error from overly simple assumptions, which causes underfitting. Variance is error from sensitivity to the particular training sample, which causes overfitting. Increasing model complexity usually lowers bias but raises variance. The goal is the complexity that minimises total test error. For example, a linear model on curved data has high bias, while a very deep unpruned tree has high variance.
12
What is multicollinearity and how do you detect it?
Multicollinearity is high correlation between input features, which makes linear model coefficients unstable and hard to interpret, though predictions may remain fine. Detect it with a correlation matrix or the Variance Inflation Factor, where VIF above 5 to 10 signals a problem. Fix it by dropping one of the correlated features, combining them, using PCA, or applying Ridge regularisation.
13
The segments you built six months ago no longer match customer behaviour. What do you do?
I would measure drift by comparing feature distributions and segment sizes over time. Then refit clustering on recent data and map new clusters to old ones by centroid similarity so business names stay consistent. I would set up a quarterly refresh with stability checks and alert when segment sizes shift sharply, and explain any renamed or merged segments to stakeholders.
14
Find the most similar items using cosine similarity.
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.neighbors import NearestNeighbors
X = TfidfVectorizer(min_df=2).fit_transform(df['title'])
nn = NearestNeighbors(n_neighbors=6, metric='cosine').fit(X)
dist, idx = nn.kneighbors(X[0])
print(df['title'].iloc[idx[0][1:]].tolist())
The first neighbour is the item itself, so skip it.
15
Your classifier works well overall but poorly for one customer segment. What do you do?
I would measure metrics per segment to confirm, then check if that segment is under-represented or has different feature distributions. Fixes include collecting more data, sample weighting, segment-specific features, or a separate model if the behaviour is truly different. If the segment relates to a protected attribute, I would also review fairness metrics and involve the compliance team.
16
What is a Gaussian Mixture Model and how is it different from k-means?
A GMM assumes data comes from a mix of Gaussian distributions and fits their means, covariances and weights with the Expectation-Maximisation algorithm. Unlike k-means' hard assignments, GMM gives soft probabilities of belonging to each cluster and can model elliptical clusters of different sizes. You can choose the number of components using BIC or AIC.
17
When would you use AdaBoost and how does it re-weight samples?
AdaBoost trains weak learners, usually decision stumps, in sequence. After each round it increases the weights of misclassified samples so the next learner focuses on them, and gives each learner a vote weight based on its accuracy. It works well on clean data but is sensitive to noisy labels and outliers, which get ever larger weights. Gradient boosting is a generalisation that has largely replaced it.
18
A model's accuracy dropped 10 percent over three months in production. How do you investigate?
I would first check data pipelines for broken features, nulls or schema changes, then compare current feature distributions with training data using PSI to find drift. I would check whether the label definition or business process changed, and analyse errors by segment. If drift is real, retrain on recent data, possibly with time-weighted samples, and set up automatic drift alerts and scheduled retraining.
19
How do you choose a classification threshold that maximises F1?
from sklearn.metrics import precision_recall_curve
import numpy as np
proba = clf.predict_proba(X_val)[:, 1]
p, r, t = precision_recall_curve(y_val, proba)
f1 = 2 * p * r / (p + r + 1e-9)
best = t[np.argmax(f1[:-1])]
print(best)
Choose it on validation data, not the test set. scikit-learn 1.5+ also offers TunedThresholdClassifierCV.
20
What is regularisation in general and why does it reduce overfitting?
Regularisation adds a constraint or penalty that discourages overly complex models, such as large weights in linear models, deep trees or too many boosting rounds. It trades a little extra bias for a larger drop in variance, so test error falls. Examples include L1 and L2 penalties, dropout in neural networks, early stopping, pruning and limiting tree depth.
Use the same data splits and folds, the same preprocessing inside pipelines and the same metric tied to the business goal. Look at the mean and standard deviation across folds, not one number, and use a paired test like a corrected t-test or bootstrap on the fold differences. Also compare cost factors: latency, memory, interpretability and maintenance.
Data drift, or covariate shift, means the distribution of input features changes, such as average order value rising after a pricing change. Concept drift means the relationship between features and target changes, such as fraud patterns evolving. Data drift can be detected without labels using PSI or KS tests; concept drift usually needs labels and shows up as falling performance. Both trigger investigation and retraining.
23
Your preprocessing works in notebooks but gives different results in production. Why?
Common causes are preprocessing written separately in two places, statistics like means recomputed on production data instead of using training values, different library versions, or different column order and data types. The fix is to save one fitted Pipeline with preprocessing and model together, pin versions, validate input schema, and test that the saved pipeline gives identical outputs on sample rows.
24
Marketing wants customer segments for campaigns. How do you approach it?
I would agree on the purpose first, such as retention or upsell. Then build RFM features (recency, frequency, monetary) plus category preferences, log-transform skewed values and scale them. I would try k-means for k between 3 and 8, use silhouette and business review to pick k, profile each segment and give them clear names. Finally, test segment-based campaigns against a control group.
25
Business users do not trust a gradient boosting model because it is a black box. How do you help?
I would use SHAP to show global drivers with a summary plot and explain individual decisions with waterfall plots, such as why one applicant got a high risk score. I would also check that the top drivers make business sense, add monotonic constraints where logic requires it, and share a few real case examples. If trust is still an issue, a scorecard model can serve as a transparent benchmark.
26
Explain a single prediction with SHAP for a tree model.
import shap
explainer = shap.TreeExplainer(model)
sv = explainer(X_val)
shap.plots.waterfall(sv[0])
shap.plots.beeswarm(sv)
The waterfall shows how each feature pushes one prediction up or down from the base value; the beeswarm shows global importance and direction. TreeExplainer is fast and exact for tree ensembles.
27
Calculate the Population Stability Index for a feature.
from sklearn.metrics import confusion_matrix, classification_report
pred = clf.predict(X_test)
print(confusion_matrix(y_test, pred))
print(classification_report(y_test, pred, digits=3))
The report shows precision, recall, F1 and support per class plus macro and weighted averages. ConfusionMatrixDisplay.from_estimator draws it as a plot.
29
Tell me about a time you took a model from notebook to production.
Situation: our demand model ran only in a notebook on my laptop. Task: make it run daily for 300 stores. Action: I refactored it into modules with a scikit-learn pipeline, added tests and input checks, containerised it with Docker and scheduled it with Airflow writing forecasts to the warehouse. Result: forecasts became available by 6 a.m. daily without manual work, and failures triggered alerts instead of silent gaps.
30
When would you use Huber or quantile regression instead of OLS?
Huber regression uses squared loss for small errors and absolute loss for large ones, so it resists outliers while staying smooth. Quantile regression predicts a chosen percentile, such as the 90th percentile of delivery time, which is useful for setting safe promises or prediction intervals. Gradient boosting libraries support both losses for non-linear versions.
31
How do you decide when a model is good enough to stop tuning?
I agree on a target metric and business threshold before starting, such as recall of 70 percent at 90 percent precision. I stop tuning when gains fall below the noise between CV folds or when further work costs more than the expected value. In one project I stopped at a 0.3 percent gain and spent the time on monitoring instead, which proved more useful.
32
What is Local Outlier Factor and how does it differ from Isolation Forest?
Local Outlier Factor compares the local density of a point with the density of its neighbours; a point in a much sparser area than its neighbours gets a high outlier score. It catches local anomalies inside varied-density data but is distance-based, so it needs scaling and is slower on large data. Isolation Forest is tree-based, faster and scales better, but is less sensitive to local density differences.
33
Describe a project where you improved a model's performance significantly.
Situation: a product-return prediction model had 0.68 AUC with logistic regression. Task: improve it for a warehouse pilot. Action: I engineered features like past return rate per customer and category, moved to LightGBM with early stopping, and tuned it with Optuna on time-based folds. Result: AUC rose to 0.81, and the pilot reduced avoidable returns in two categories. I documented each step's gain.
34
Your tree model predicts higher risk for customers with higher income, which is illogical. What do you do?
First check whether data supports it, perhaps due to confounding or a small segment. If the relationship should be one-directional for business or regulatory reasons, I would apply monotonic constraints, available in XGBoost, LightGBM and HistGradientBoosting, so risk can only decrease with income. Then compare validation metrics; usually the loss is small and the model becomes more trustworthy.
35
How do you prioritise when several teams ask you for models at the same time?
I estimate each request's business value, effort and urgency, then share a ranked list with my manager so priorities are agreed rather than assumed. For quick wins I offer a simple baseline first. In one quarter this helped us deliver a high-value churn model first while giving another team a dashboard-based interim answer, and both teams knew the timeline.
Stacking trains several diverse base models and then a meta-model on their out-of-fold predictions to combine them. It often gives a small accuracy gain, common in competitions. In production it adds complexity, latency and maintenance, so it is worth it only when the gain has clear business value. scikit-learn provides StackingClassifier and StackingRegressor.
37
What is training-serving skew and how do you prevent it?
Training-serving skew is when features at prediction time are computed differently from features used in training, causing silent accuracy loss. Causes include separate code paths, different data sources, or time windows that use future data in training. Prevent it by sharing one feature-computation code path or a feature store, logging served features and comparing their distributions with training data.
38
Your model must run on a mobile app with no internet. What do you consider?
Model size, memory and latency on low-end phones become key. I would choose a compact model, reduce features, and convert it to a mobile format such as ONNX, TensorFlow Lite or Core ML, applying quantisation if needed. I would make sure all preprocessing is replicated on-device, test accuracy after conversion, and plan how model updates will ship with app releases.
39
You need prediction intervals, not just point estimates, for delivery time. How?
Options are quantile regression, training separate models for the 10th and 90th percentiles with GradientBoostingRegressor(loss='quantile') or LightGBM; conformal prediction, which wraps any model and gives intervals with guaranteed coverage; or bootstrapping. I would check calibration: about 80 percent of actual values should fall within an 80 percent interval on a holdout set.
The kernel trick computes dot products of data in a high-dimensional feature space without explicitly transforming the data, using a kernel function such as RBF, exp(-gamma times squared distance). This lets linear algorithms like SVM learn non-linear boundaries efficiently. In RBF SVMs, larger gamma makes each point's influence more local, which can lead to overfitting.
Frequently asked questions
What is asked in Machine Learning interviews for 7 years of experience?
Seven-year candidates are usually considered for lead or staff roles. Interviewers focus on strategy and leadership: building an ML roadmap, setting evaluation standards, managing stakeholders, handling failed projects and balancing research with delivery. Technical depth is still tested through design discussions on large-scale data, model risk and platform choices. Expect panel discussions.
How many questions should I practise before a Machine Learning interview?
Work through all 40 questions here, then the company-wise sets for the employers you are targeting. Quality matters more than count: be able to explain why each answer is right.
Which topics matter most for 7 years of experience?
Focus first on ML roadmap and strategy, Team leadership, Model governance, Platform decisions.