Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.
About Walmart hiring for Machine Learning roles
Walmart is a global retailer operating stores and e-commerce, and it owns Flipkart and PhonePe in India. Walmart Global Tech India in Bengaluru and Chennai builds software, data and analytics solutions for Walmart's global businesses. It hires for software engineers, SDETs, data engineers, data scientists and analysts working on supply chain, pricing and customer platforms.
For Machine Learning roles, this Walmart practice set focuses most on Decision Trees and Ensembles (7), ML Fundamentals (5), MLOps and Deployment (5), Regression Models (4). It has 1 easy, 24 medium, 5 hard questions, so you can start easy and work up to the harder ones.
Company type
E-commerce & consumer tech
Headquarters
Bentonville, Arkansas, USA
Main India offices
Bengaluru, Chennai, Gurugram
Walmart Machine Learning interview process
Online coding assessment
Technical round 1 (DSA)
Technical round 2 (design or domain)
Hiring manager round
HR round
Typical pattern based on public candidate experiences. Rounds vary by role, team and year.
Solved for WalmartStart 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 you create polynomial features with regularisation in a pipeline?
from sklearn.preprocessing import PolynomialFeatures, StandardScaler
from sklearn.linear_model import Ridge
from sklearn.pipeline import make_pipeline
model = make_pipeline(
PolynomialFeatures(degree=2, include_bias=False),
StandardScaler(),
Ridge(alpha=1.0)
)
model.fit(X_train, y_train)
Tune degree and alpha together with GridSearchCV to avoid overfitting.
02
Leadership wants a model in one week, but data quality is poor. How do you handle it?
I would agree on a narrow first version: a simple, explainable baseline built on the cleanest available fields, with clear notes on data gaps and expected accuracy. In parallel I would log specific data issues and their impact. Delivering a working baseline with an honest limitations section builds trust and gives a reference point for improvement in later iterations.
03
You are asked to predict customer churn. How would you frame the ML problem from scratch?
First define churn precisely, for example no purchase in 60 days, and the prediction window. It becomes binary classification. Build features from data available before the cut-off date only, choose a time-based split, and pick metrics like recall at a fixed precision or lift in the top decile. Start with logistic regression as a baseline, then try boosting, and agree on how retention teams will use the scores.
Gradient boosting starts with a simple prediction, like the mean, then repeatedly fits a small tree to the negative gradient of the loss, which for MSE is just the residuals. Each tree's output is scaled by a learning rate and added to the ensemble. A lower learning rate with more trees usually generalises better. Any differentiable loss can be used, which makes it flexible.
05
Your random forest model file is 2 GB and too slow for real-time scoring. What can you do?
Reduce size by limiting max_depth and min_samples_leaf, using fewer trees since gains flatten after a few hundred, and dropping weak features. Alternatively switch to a gradient boosting model like LightGBM, which usually gives similar accuracy with far smaller, faster models. Converting to ONNX or using a compiled predictor can also speed up inference. Measure accuracy and latency after each change.
06
What is the no free lunch theorem and what does it mean in practice?
It states that no single algorithm is best for every problem when averaged over all possible problems. In practice it means you should try several model families, start with a simple baseline, and choose based on validation results for your data. For tabular data gradient boosting often wins, but a logistic regression may be preferred if interpretability matters more.
07
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.
08
What should you monitor for a model in production?
Monitor service health such as latency, error rate and throughput; input data quality such as missing values, schema changes and out-of-range values; feature and prediction distribution drift; and real performance once labels arrive. Also track business KPIs the model influences. Set alerts with thresholds and owners, and keep a dashboard so issues are found before users report them.
09
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.
10
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.
11
A new model has slightly better AUC but worse precision in the top 1,000 cases the team acts on. Which do you pick?
I would pick the model that does better where decisions are actually made. If the team only reviews the top 1,000 cases, precision at 1,000 or recall at that cut-off matters more than global AUC. I would make that the primary metric in future comparisons, and confirm the result holds across several time periods before switching.
12
Random forest and LightGBM give the same AUC. Which would you deploy?
I would compare beyond AUC: model size, inference latency, training time, calibration and stability across time periods. LightGBM is usually smaller and faster to score, while random forest needs less tuning and is less prone to overfitting. If both are equal, I would choose the one that is cheaper to run and easier for the team to maintain and retrain.
13
Tell me about a time you discovered your own mistake after sharing results.
Situation: after presenting a 12 percent uplift from a pricing model, I found my evaluation used a random split on time-series data. Task: correct it quickly. Action: I re-ran with a time-based split, which showed 7 percent, and informed my manager the same day with the corrected analysis. Result: the team appreciated the honesty, the rollout plan used the right number, and I added split checks to our review template.
14
Validation AUC is 0.99 on a loan default model. What do you suspect?
Such a high score on a hard problem usually signals leakage. I would check feature importances for a suspiciously dominant feature, look for fields recorded after the loan outcome such as collection status, verify preprocessing was fit only on training data, and check for duplicate customers across train and test. Then re-run with a time-based split to confirm a realistic score.
15
Your training loss is not decreasing at all. What could be wrong?
Common causes are a learning rate that is too high or too low, unscaled features, a bug in labels or feature alignment, wrong loss for the task, or data that has been shuffled away from its labels. I would try overfitting a tiny subset first; if the model cannot even fit 50 rows, there is a bug. Then check scaling, learning rate and gradient values.
16
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.
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.
18
Use statsmodels to get p-values for regression coefficients.
import statsmodels.api as sm
Xc = sm.add_constant(X_train)
ols = sm.OLS(y_train, Xc).fit()
print(ols.summary())
The summary shows coefficients, standard errors, p-values, confidence intervals, R-squared and diagnostics. scikit-learn focuses on prediction and does not report p-values, so statsmodels is preferred for inference.
import lightgbm as lgb
m = lgb.LGBMClassifier(n_estimators=5000, learning_rate=0.05,
num_leaves=31, subsample=0.8, subsample_freq=1, colsample_bytree=0.8)
m.fit(X_train, y_train, eval_set=[(X_val, y_val)],
eval_metric='auc', callbacks=[lgb.early_stopping(100)])
print(m.best_iteration_)
The large n_estimators is only an upper limit; early stopping picks the real number.
20
What is the difference between offline evaluation and online A/B testing of a model?
Offline evaluation measures metrics like AUC on historical holdout data; it is fast and cheap but cannot capture user behaviour changes or feedback loops. Online A/B testing exposes a share of real traffic to the new model and measures business outcomes like conversion or loss rate. Offline gains do not always translate online, so important models are validated with A/B tests or shadow deployments.
21
Build RFM features for customer segmentation in pandas.
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.
from sklearn.ensemble import IsolationForest
iso = IsolationForest(n_estimators=300, contamination=0.01, random_state=42)
iso.fit(X_train)
scores = -iso.score_samples(X_new)
flags = iso.predict(X_new) == -1
Higher scores mean more anomalous. Tune contamination to match how many alerts reviewers can handle.
from sklearn.tree import DecisionTreeClassifier, export_text, plot_tree
import matplotlib.pyplot as plt
dt = DecisionTreeClassifier(max_depth=3, random_state=0).fit(X_train, y_train)
print(export_text(dt, feature_names=list(X_train.columns)))
plot_tree(dt, feature_names=X_train.columns, filled=True)
plt.show()
Shallow trees are a good way to explain rules to business teams.
27
Use HistGradientBoosting with native categorical support in scikit-learn.
from sklearn.ensemble import HistGradientBoostingClassifier
clf = HistGradientBoostingClassifier(
categorical_features='from_dtype', max_iter=500,
learning_rate=0.05, early_stopping=True, random_state=42)
X_train[cat_cols] = X_train[cat_cols].astype('category')
clf.fit(X_train, y_train)
It handles missing values natively and is much faster than GradientBoostingClassifier on large data.
28
A demand forecast is consistently under-predicting during festivals. How would you fix it?
The model lacks festival information. I would add features for festival dates such as Diwali or regional holidays, days-to-festival, and past festival uplift for the same item. If the business cost of stock-outs is higher than over-stock, I would use a quantile loss for a higher percentile. Then validate specifically on past festival periods, not just the average error.
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.
30
What is the difference between Ridge, Lasso and Elastic Net regression?
All add a penalty on coefficient size to reduce overfitting. Ridge uses an L2 penalty (sum of squares), shrinking coefficients toward zero but rarely to zero, and handles multicollinearity well. Lasso uses L1 (sum of absolute values) and can set coefficients exactly to zero, performing feature selection. Elastic Net mixes both, which is useful when there are groups of correlated features.
Tips to crack the Walmart Machine Learning interview
Think about retail problems like inventory forecasting, store replenishment and pricing, which Walmart data teams commonly work on.
Practise DSA and SQL questions together, since many roles combine coding with data handling.
Read Walmart's values of Respect for the Individual, Act with Integrity, Serve Our Customers and Strive for Excellence.
Keep a one-minute story ready for every project on your CV: problem, your part, tools, result.
Practise the hard questions on this page aloud; Walmart interviewers usually ask follow-ups on your first answer.
Frequently asked questions
How many rounds are there in the Walmart Machine Learning interview?
Candidates usually go through 5 stages: Online coding assessment; Technical round 1 (DSA); Technical round 2 (design or domain); Hiring manager round; HR round. The exact rounds change with the role, team, location and your experience, so confirm the process with the recruiter.
Which topics should I prepare for the Walmart Machine Learning interview?
This practice set leans on Decision Trees and Ensembles (7), ML Fundamentals (5), MLOps and Deployment (5), Regression Models (4). Revise those first, then practise explaining one or two of your own projects end to end, because most Walmart interviewers ask you to walk through real work.
Are these the exact questions asked at Walmart?
No. These are curated practice questions that match the skills and difficulty usually tested in e-commerce & consumer tech interviews like Walmart's. They are not a leaked or verified list of past questions.
Where does Walmart hire Machine Learning professionals in India?
Walmart has large teams in Bengaluru, Chennai, Gurugram. Openings and locations change often, so check the Walmart careers page and filter by city and experience.