Machine Learning Engineer Interview Questions — Machine Learning

9 Machine Learning questions asked in machine learning engineer interviews, ordered by how often they come up. Read the quick answer, say it out loud, then check the full reasoning.

9 questions Updated November 2026
Very Common Easy Q1 / 9

What is machine learning, and when would you build a rule-based system instead?

The 40-second answer

Machine learning means a program learns the link between inputs and an outcome from past examples instead of a person writing the logic. Build rules when the logic is known, stable and must be exactly right, like a refund policy. Use machine learning when the pattern is real but too tangled for anyone to write down.

Interviewers ask this to see whether you reach for a model by reflex.

Take Indian Railways. The refund on a cancelled ticket is set by policy: a deduction that depends on the class of travel and the hours left before departure. The rules are written down and the right answer is never in doubt. A model trained on past refunds could only approximate them, and when the policy changes you would retrain instead of editing one line. Rules win.

Now ask: will a ticket at WL 37 on a Diwali-week train to Patna get confirmed? It depends on the route, the quota, the days left, how many people usually cancel on that train in that season, and how those interact. Nobody can write that as if-else conditions, but millions of past bookings with known outcomes contain the pattern. Machine learning learns the mapping from examples when you have labelled history but cannot state the logic.

A quick test you can say out loud:

  • Can an expert write the rule completely? Then write it.
  • Is there enough history with known outcomes? If not, a model has nothing to learn from.
  • Can the business live with being wrong some of the time?
  • Does the pattern shift? Then you need a way to keep the model current.

The misconception is that machine learning is a smarter kind of rule. It is an estimate that will be wrong on some fraction of cases. Often the two sit together: rules as guardrails around a model.

What they ask next
  • The railway changes its refund policy next month. What happens to a model that learned the old refunds from history?
  • You have rules today and a model that beats them offline. How would you combine the two instead of replacing one with the other?
  • What would make you abandon a machine learning project in its first week?
Very Common Easy Q2 / 9

Can you explain supervised, unsupervised and reinforcement learning, with a business example of each?

The 40-second answer

Supervised learning learns from examples where the right answer is known, such as which players made a purchase. Unsupervised learning has no answer column and looks for structure, such as groups of similar players. Reinforcement learning takes actions, receives a reward afterwards and gradually learns which actions pay off, such as tuning game difficulty.

Separate them by the feedback the algorithm gets. A mobile gaming studio running a cricket game can use all three.

Type What the data gives you Example in the game
Supervised Inputs plus the correct answer for past cases Predict which new players will make an in-app purchase in week one, learned from players whose week one is already over
Unsupervised Inputs only, no answer column Group players by session length, time of day, match format and spend to find natural segments
Reinforcement A reward that arrives after the system acts Choose the difficulty of the next match, observe whether the player keeps playing, and adjust

Supervised is where most business value sits, because most business questions have an outcome you can record.

Unsupervised is useful for exploration, but clusters come with no names. A person still has to look at five groups and decide that one is “weekend binge players”. Different features give different clusters, so treat them as a lens, not a discovery.

Reinforcement learning is the one candidates describe loosely. Nobody tells the system the right difficulty. It tries something, gets a reward later (the player stayed, or quit), and learns a policy. So it must be allowed to experiment on real users, including bad choices while it learns.

A misconception worth correcting in the room: reinforcement learning is not supervised learning with more data. The difference is that the system’s own actions change what data it sees next.

What they ask next
  • Your clustering gives five player segments. How do you convince the product head they are real and not an artefact of the features you picked?
  • Why would a team choose a simple supervised model over reinforcement learning even when the problem looks like a sequence of decisions?
  • You have labels for only two percent of your players. Which of the three do you use, and why?
Very Common Easy Q3 / 9

What is the difference between regression and classification, and can you give a problem that could be framed as either?

The 40-second answer

Regression predicts a number on a continuous scale, such as a used car's sale price. Classification predicts a category, such as whether the car sells within 30 days. Many problems can be framed either way, and the right framing comes from the decision the business will make with the prediction, not from the data.

Picture an online used-car marketplace with listings across Indian cities.

Regression answers “how much” or “how many”. What price will this 2019 hatchback in Pune sell for? If the model says ₹5.1 lakh and the car sells for ₹4.8 lakh, you were off by ₹30,000, an error with a size you can average.

Classification answers “which one”. Will this car sell within 30 days, yes or no? Each prediction is simply right or wrong, and you usually get a probability you can turn into a decision.

Now take days-to-sell. You could predict the number of days (regression), ask “sold within 30 days?” (classification), or predict a band (multi-class). All three are defensible. The deciding question, and one worth asking the interviewer, is what action follows the prediction. If a dealer only decides whether to discount a car now or wait, a yes or no answer matches the decision. If the pricing team wants to plan cash flow, the number of days is what they need.

Converting a number into a class throws information away. With a 30-day cutoff, a car that sells in 29 days and one that sells in 2 days become identical, while a 29-day car and a 31-day car land on opposite sides. Do it only when the decision has a cutoff.

One trap interviewers enjoy: logistic regression is a classifier. It outputs a probability, and a threshold turns that into a class.

What they ask next
  • You turned days-to-sell into a yes or no at 30 days. Where exactly does that cutoff come from, and who should choose it?
  • A car sells on day 31. Your classifier said 0.9 for selling within 30 days, and a regression model said 28 days. Which model was more wrong?
  • Your price model is right on average but badly wrong on luxury cars. Would switching to price bands fix that?
Very Common Medium Q4 / 9

Why do we split data into training, validation and test sets, and what goes wrong if you only use two?

The 40-second answer

The training set fits the model, the validation set chooses between models, settings and features, and the test set is used once at the end to estimate performance on new data. With only two sets you end up tuning on the test set, so its score becomes optimistic, and you lose your only honest estimate.

Each set answers a different question, and mixing them up quietly destroys the answer.

  • Training set: the model learns its parameters here.
  • Validation set: you compare choices here. Which algorithm, which tree depth, which features, which threshold.
  • Test set: touched once, after every choice is final, to estimate how the chosen model will do on data it has never influenced.

Picture a rental platform in Bengaluru predicting a fair monthly rent for new listings. It has 10,000 past listings and splits them 70/15/15: 7,000 for training, 1,500 for validation, 1,500 for test.

With only train and test, the test set does the validation job. You try 40 configurations and keep the one with the best test error. That number is now flattered, because you picked the configuration that happened to suit those particular 1,500 flats. (Why picking the best of many inflates a score is a statistics question in its own right.) Say the winner shows a mean absolute error of ₹2,100 on that set; on genuinely new listings next quarter it lands at ₹2,650, about 26% worse. With a separate test set you would have seen that gap before launch. Without it, you find out from unhappy landlords.

Two practical points interviewers like to hear:

  1. The split must mimic deployment. If the model will price next quarter’s listings, the test set should come from a later period than the training data, not a random draw. If the same flat appears several times, keep all its rows in one set, or the model is tested on flats it has already seen.
  2. A test set used to make a decision is no longer a test set. If you look at the test score, change something and look again, you have turned it into a second validation set. Holding the line on this takes discipline, especially near a deadline.

When data is small, cross-validation on the training portion can stand in for a fixed validation set, which frees more rows for learning. The test set still stays locked away.

What they ask next
  • The same flat gets relisted three times a year with a new listing ID. How do you split so it does not leak across sets?
  • You have only 1,200 rows. Would you still hold out a fixed validation set?
  • Your test score comes back much worse than validation. You are tempted to tweak and re-test. What do you do instead?
Very Common Medium Q5 / 9

How do you tell from training and validation scores whether a model is overfitting or underfitting?

The 40-second answer

Compare the two scores and a sensible target. Underfitting shows as both scores low and close together: the model is too simple to capture the pattern. Overfitting shows as a high training score with a clearly lower validation score: the model has memorised details of its training rows. The gap matters more than how high training looks.

The misconception to correct first: a very high training score is not proof of overfitting. A model scoring 0.99 on training and 0.98 on validation is fine. What tells you something is the gap, read alongside a target for what good looks like.

Here is a quick experiment on synthetic data standing in for flight records, where the label is whether a domestic flight departs more than 15 minutes late. Roughly half the flights are delayed, so guessing gets you about 0.52. Three decision trees of increasing depth:

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier

X, y = make_classification(n_samples=3000, n_features=12, n_informative=5,
                           flip_y=0.1, random_state=7)
X_tr, X_val, y_tr, y_val = train_test_split(X, y, test_size=0.25, random_state=7)

for depth in [1, 5, None]:
    tree = DecisionTreeClassifier(max_depth=depth, random_state=7).fit(X_tr, y_tr)
    print(depth, round(tree.score(X_tr, y_tr), 3), round(tree.score(X_val, y_val), 3))
1 0.769 0.756
5 0.863 0.849
None 1.0 0.807
Depth Train Validation Reading
1 0.769 0.756 Underfitting: both low, almost no gap, the model is too simple
5 0.863 0.849 Healthy: higher on both, small gap
Unlimited 1.000 0.807 Overfitting: perfect on training, worse on validation than depth 5

The unlimited tree grew a leaf for almost every training flight, including the 10% of rows whose labels the generator assigned at random. It learned that noise as if it were a pattern, and paid for it on new flights.

What to do next depends on the diagnosis. For underfitting, give the model more capacity: deeper trees, more features, less regularisation. For overfitting, take capacity away or add information: limit depth, regularise, add training data, or average many models.

Two things make this harder in real work. First, small validation sets are noisy, so a gap of 0.01 may mean nothing. Second, “both scores low” is only underfitting if a better score is achievable. If the labels themselves are noisy, 0.85 might be the ceiling. Ask the interviewer whether there is a human or business benchmark to compare against.

What they ask next
  • Your validation score is slightly higher than your training score. Is something broken?
  • Training and validation are both 0.85 and close together. How do you decide whether that is underfitting or simply the best this data allows?
  • You have a big train-validation gap but cannot get more data. What are your next three experiments, in order?
Very Common Hard Q6 / 9

Can you explain the bias-variance tradeoff as it applies to choosing a model?

The 40-second answer

Bias is error from a model too simple to capture the real pattern; variance is error from a model so flexible that it changes a lot with each training sample. Expected error on new data is roughly bias squared plus variance plus irreducible noise. Adding flexibility lowers bias but raises variance, so you look for the balance point.

Imagine a phone refurbisher that grades used smartphones and wants to predict battery health (as a percentage of original capacity) from the number of charge cycles. Health falls slowly at first, then faster after about a thousand cycles. That bend is the real pattern.

Now picture training the same kind of model many times, each time on a different random sample of 30 phones, and asking each version to predict health at 1,800 cycles.

  • Bias is how far the average of those predictions sits from the truth. A straight line cannot bend, so every version misses the curve in the same direction.
  • Variance is how much the predictions scatter from one sample to the next. A very wiggly curve chases each sample’s noise, so every version lands somewhere different.
  • Noise is the part no model can remove: two phones with the same cycle count still differ.

That is the decomposition in words: expected squared error on a new phone is bias squared plus variance plus noise. A small simulation makes it concrete, with polynomials of degree 1, 3 and 8:

import numpy as np

rng = np.random.default_rng(0)
health = lambda k: 100 - 4 * k - 3 * k ** 3    # k = thousands of charge cycles
k0 = 1.8                                        # predict health at 1,800 cycles
for deg in [1, 3, 8]:
    preds = []
    for _ in range(500):                        # 500 different training samples
        k = rng.uniform(0, 2, 30)
        y = health(k) + rng.normal(0, 2, 30)
        preds.append(np.polyval(np.polyfit(k, y, deg), k0))
    preds = np.array(preds)
    bias_sq = (preds.mean() - health(k0)) ** 2
    print(f"degree {deg:2d}: bias^2 {bias_sq:5.2f}  variance {preds.var():5.2f}")
degree  1: bias^2  9.09  variance  1.82
degree  3: bias^2  0.00  variance  0.77
degree  8: bias^2  0.04  variance 14.41

The noise has a standard deviation of 2 points, so it contributes 4 to every model. Adding it up, the expected squared error at 1,800 cycles is about 14.9 for the straight line, 4.8 for the cubic and 18.5 for the degree-8 curve. The straight line is wrong for structural reasons. The degree-8 curve can bend correctly on average, but any single fit is unreliable.

What moves each side. Bias falls when you add flexibility: a more expressive model, better features, less regularisation. Variance falls when you add data, regularise, simplify, or average many models. One misconception worth correcting is that more data fixes everything. It shrinks variance, but a straight line trained on a million phones still cannot bend.

The other misconception is that you must always trade one for the other. The cubic wins on both counts here because its shape matches the truth, and bagging lowers variance without adding much bias. In real work you never know the true shape, which is why you compare complexities on validation data. (The bias and variance of an estimator in the statistical sense is a separate question; this is the modelling version.)

What they ask next
  • Your model has high bias. Will collecting ten times more data fix it, and why or why not?
  • Random forests use very deep trees, which have high variance. Why does the forest not overfit as badly as one deep tree?
  • In the simulation, how would the three results change if the noise in battery readings doubled?
Very Common Medium Q7 / 9

How does k-fold cross-validation work, and when should you not shuffle the data before splitting?

The 40-second answer

k-fold cross-validation splits the training data into k parts, trains on k minus one of them, scores on the one held out, and rotates until every part has been held out once. Shuffle when rows are independent. Do not shuffle blindly when rows are ordered in time or when several rows belong to the same entity.

The mechanics are short. Split the rows into k folds, often 5 or 10. With k = 5, train on four folds, score on the fifth, repeat five times so each fold is held out exactly once, and average the scores. Every row gets scored by a model that never saw it, and you use all your data for both learning and checking. (How much those fold scores vary, and what that spread tells you, is a statistics question.)

The interesting part is how the folds are drawn.

  • Stratified folds keep the class proportions the same in every fold. If only 4% of rows are positive, an unlucky plain split could leave one fold with almost none.
  • Grouped folds keep all rows of one entity in the same fold. This matters far more than people expect.
  • Forward-in-time folds train on the past and test on the future when time order matters.

Here is the grouped case. A dairy cooperative wants to predict monthly milk yield per cow from feed and body weight, with 12 monthly records for each of 80 cows. Body weight barely changes month to month, so it acts as a fingerprint for each cow.

import numpy as np
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import KFold, GroupKFold, cross_val_score

rng = np.random.default_rng(42)
cow = np.repeat(np.arange(80), 12)                 # 80 cows, 12 monthly records each
body_wt = rng.normal(450, 40, 80)[cow]             # body weight, fixed per cow
feed = rng.normal(14, 2, cow.size)                 # kg of feed that month
milk = 0.6 * feed + rng.normal(0, 3, 80)[cow] + rng.normal(0, 1, cow.size)
X = np.column_stack([body_wt, feed])

model = RandomForestRegressor(n_estimators=200, random_state=0)
shuffled = cross_val_score(model, X, milk, cv=KFold(5, shuffle=True, random_state=0))
grouped = cross_val_score(model, X, milk, cv=GroupKFold(5), groups=cow)
print("shuffled KFold R2:", shuffled.mean().round(2))
print("GroupKFold R2:   ", grouped.mean().round(2))
shuffled KFold R2: 0.64
GroupKFold R2:    -0.43

With shuffled folds, each cow’s other eleven months sit in training, so the forest recognises the cow by its weight and recalls its yield. On cows it has never seen, the same model does worse than simply predicting the average yield. The 0.64 was measuring memory, not skill.

So when should you not shuffle? When rows are ordered in time and the model will predict the future, because shuffling hands it tomorrow’s information. And when rows cluster by entity, where you should group instead. Shuffling is right when rows are independent and the file happens to be sorted, say by region or by label, so that unshuffled folds would be lopsided.

The clarifying question to ask: will the model score new entities, or the same ones later? The answer decides the split.

What they ask next
  • If the model will predict the same cows next month rather than new cows, would you still group by cow? What would you do instead?
  • Your five fold scores are 0.71, 0.69, 0.74, 0.31 and 0.70. What do you investigate first?
  • Why is stratification usually unnecessary for a regression target, and when would you want something like it anyway?
Common Medium Q8 / 9

How do you frame a machine learning problem: what is the label, what are the features, and when is the prediction made?

The 40-second answer

Framing means fixing three things before any modelling: the label (exactly what outcome you predict), the moment of prediction (when the model runs and what action follows), and the features (only information available at that moment). Getting the moment wrong is the most common failure, because it lets future information leak into training and makes a useless model look excellent.

Most failed projects die here, long before anyone tunes a model. Take a hotel chain with properties across Rajasthan that wants to predict booking cancellations.

Start with the decision, then the moment. Ask the interviewer what the hotel will do with the prediction. Suppose the revenue team overbooks rooms it expects to be cancelled, and it sets inventory 14 days before check-in. Then the model runs at T minus 14 for every booking with check-in at least 14 days away. A model that predicts cancellations the night before check-in might be very accurate and completely useless, because nobody can resell a room at that point.

The stakes are concrete. A 120-room property with a 15% cancellation rate is left with 18 empty rooms a night if it does nothing.

Then define the label precisely. “Cancelled” hides choices:

  • Does a no-show count? It costs the hotel the same as a late cancellation, so probably yes.
  • Does a date change count? Probably not, the guest still comes.
  • A cancellation made 20 days out is outside the window, because the booking was already gone before the prediction moment.

So the label might be: cancelled or no-show between T minus 14 and check-in.

Features are only what was known at T minus 14. Lead time, booking channel, whether a deposit was paid, room type, the guest’s past cancellation history, and how many times the booking has been modified so far. Not the refund status, not the final room assignment, not anything written into the record later.

That last point is where teams get hurt. The bookings table usually stores each booking’s current state, overwritten as things happen. If you train on it directly, a field like “number of modifications” includes edits made after T minus 14, often by guests who were about to cancel. Validation looks superb, then the live model disappoints. The fix is to build each training row as a snapshot of the booking as it looked at the prediction moment.

The misconception to correct: “use every column in the table”. Every feature should pass one test: would I have had this value, with this exact content, when the model runs?

What they ask next
  • The revenue team now wants a second prediction at 3 days before check-in as well. Is that one model or two, and what changes in the training data?
  • Half your bookings came through travel agents who never record cancellations properly. How does that affect your label?
  • How would you build training rows if the bookings table only stores each booking's latest state?
Common Medium Q9 / 9

Can you walk me through the workflow from a business question to a model that people actually use?

The 40-second answer

Start from the decision and how success will be measured, set a simple baseline, then build data, features and a model validated the way it will be used. Most of the work comes after the model: fitting it into an existing process, piloting it against the baseline on a business metric, and monitoring and retraining once it is live.

The candidates who stand out describe the steps around the model, because that is where projects stall. Take a pharmacy chain with 400 stores that wants fewer stock-outs of medicines.

  1. Pin down the decision and the success metric. The real decision is the nightly reorder quantity for each medicine in each store. Success is fewer stock-out days without a jump in inventory holding cost. Model error is a means, not the goal.
  2. Write down the baseline. Today a store reorders when stock falls below seven days of average sales. Every model must beat this rule, measured the same way, or it does not ship.
  3. Get and understand the data. Sales, daily stock snapshots, supplier lead times, local events. This is where a subtle trap appears.
  4. Frame and build. Define the target, build features using only information available at ordering time, and validate forward in time.
  5. Compare offline against the baseline. On a held-out later period, on the business metric.
  6. Integrate. Scoring 400 stores by about 3,000 medicines means 12 lakh store and medicine pairs every night, delivered to the ordering system before stores open. If that pipeline is late, the model does not exist.
  7. Pilot. Run it in a set of stores alongside the old rule elsewhere, and watch the business metric.
  8. Monitor and retrain. Demand shifts with seasons and outbreaks; the model must keep up.

Now the trap from step 3. On days a medicine was out of stock, recorded sales were zero, but demand was not. Train naively on sales and the model learns that demand is low exactly where the shelf was empty, recommends smaller orders, and causes more stock-outs, which then look like more low-demand days. The fix is to treat stock-out days as censored: drop them or estimate the lost demand.

The misconception to avoid is that the workflow ends at a good validation score. Ask the interviewer who will act on the output and how, because a model that does not fit an existing process gets ignored, however accurate it is.

What they ask next
  • The pilot stores show fewer stock-outs but higher inventory cost. Who decides whether that is a success, and how would you frame it for them?
  • Store managers keep overriding the model's orders. Is that a problem to fix or a signal to use?
  • Which step in this workflow would you cut corners on if you had two weeks instead of two months?

That is every Machine Learning question in this set

Go again on anything you marked for revision, or move to the next topic.

More Machine Learning Engineer sets
Q1 / 9  ·  0% confident