Machine Learning

Machine learning interview questions: how to prepare, with worked answers

Prepare for a machine learning interview with worked questions on splits, leakage, baselines, metrics and regression, plus a practical revision plan.

Machine learning for interview preparation means being able to explain a decision, work through a small example and recognise when a reported score is misleading. Start with data splits, leakage, baselines, evaluation and one model you can explain from inputs to predictions.

The questions below are original practice prompts, not a list of questions used by any employer. Each has a worked answer and a follow-up to practise aloud. They help check understanding; they do not guarantee an interview outcome.

What to revise first

TopicWhat to explain without notesA practical check
Problem framingTarget, unit of observation and prediction timeDefine what one row represents
Data splitsWhat stays out of fitting and model selectionDraw a split that matches the use case
LeakageHow future or held-out information reaches trainingName one tempting but unavailable input
BaselinesWhat the model must improve uponCalculate a mean or majority prediction
MetricsWhich errors matter for the decisionWork through a confusion matrix
RegressionHow features become a number and how fitting changes coefficientsPredict from a simple fitted line

Use the beginner learning order if any of these topics are unfamiliar. If you want to strengthen implementation as well as explanation, use the Python project examples.

Question 1: how would you split repeat-customer data?

Prompt: a dataset has several visits from each customer. You want to estimate performance for customers the model has never seen. Is a random row split sufficient?

Worked answer: it can put visits from the same customer in both training and test data. The model may benefit from repeated customer-specific patterns, making the score a poor match for the stated goal. Split by customer so a test customer has no training visits. Fit preprocessing using training data only.

If the real goal is predicting a future visit for an existing customer, you may instead need a time-based design. The right split follows the deployment question, not a rule that one split is always best.

Follow-up: what if several customers share a household? Explain whether household information creates another grouping to consider and what population you want the test to represent.

Question 2: where is the leakage?

Prompt: a model predicts whether a support request will be escalated. An input column records the final escalation status. Why is that a problem?

Worked answer: the field directly contains the outcome and is not known when the prediction must be made. Exclude it and inspect other columns derived from later workflow steps. Renaming it does not change the information it carries.

Also check learned preprocessing: using the held-out set to choose feature transformations or tune thresholds allows evaluation information to influence decisions. Keep model selection separate from the final test.

Follow-up: a text field includes the phrase "escalated to specialist" in a note written after resolution. Explain why removing the explicit status column would not remove this second leak. See data leakage in machine learning for a fuller checklist.

Question 3: calculate precision and recall

Prompt: among 100 messages, 20 are urgent. A model flags 15, of which 12 are truly urgent. Calculate precision, recall and the number of missed urgent messages.

Worked answer: precision is 12 / 15 = 80%; recall is 12 / 20 = 60%; missed urgent messages number 20 - 12 = 8. There are three unnecessary flags. A system that never flags anything has 80% accuracy, so accuracy alone does not describe whether the queue is useful.

Follow-up: if urgent misses cost more than unnecessary reviews, would you immediately lower the threshold? A complete answer asks about the resulting review volume and measures the new trade-off on validation data. The preference for recall does not remove capacity constraints.

For a fully worked report table, read machine learning for non technical people.

Question 4: explain a regression baseline

Prompt: training targets are 12, 14, 16, 18 and 20. What does a mean baseline predict? What is its MAE on held-out targets 22 and 24?

Worked answer: the training mean is 16. The held-out absolute errors are 6 and 8, giving MAE 7. Computing the baseline from the test targets would use information that was meant to remain held out.

Now suppose a fitted model is prediction = 10 + 2x. It predicts 22 at x = 6 and 24 at x = 7. Its MAE on those two cases is zero. That is a result on a tiny constructed example, not a general claim about its accuracy. Run the linear regression tutorial to check the arithmetic in code.

Follow-up: why does a coefficient not prove causation? Give an example of an omitted factor that affects both an input and an outcome.

Question 5: explain overfitting without a slogan

Prompt: training error keeps falling as you increase model complexity, but validation error begins rising. What would you check?

Worked answer: compare the change across appropriate validation splits, inspect leakage and ask whether the data support the extra flexibility. Try a simpler model or regularisation, and compare against the same baseline. Do not repeatedly inspect the final test set while choosing among variants.

The explanation should connect the measured behavior to a concrete next experiment. "The model memorised" is incomplete unless you can show what changed and how you will evaluate an alternative. Review overfitting vs underfitting for examples.

A practical revision loop

  1. Answer one prompt aloud before reading the worked answer.
  2. Write down the assumption you missed: time, grouping, units or decision cost.
  3. Run a small example and change one input while predicting the effect.
  4. Explain the new result as though another learner needs to reproduce it.
  5. Revisit the prompt later without looking at your earlier answer.

Keep a short record of errors rather than a long collection of memorised definitions. If you cannot calculate a baseline on five values, return to that calculation before adding more algorithm names.

Common questions

Should I memorise every algorithm?

Prioritise explaining the workflow and a few models well, then expand according to the role's stated scope. Explain your assumptions and limits when a question moves beyond what you have studied.

Do I need Python for an ML interview?

Requirements vary by role. For implementation-focused work, practise ordinary Python, tabular operations and the estimator workflow alongside theory. The Python for machine learning guide gives a focused foundation.

Are these actual company interview questions?

No. They are original learning exercises built around concepts you can verify. SchoolWhool does not claim that a particular employer uses them.

Prepare through lessons and practice

SchoolWhool's learning path connects the Python, Data Tools, Maths, Statistics and Machine Learning tracks. Use each module's available interview questions to practise explanations, and its quizzes and exercises to check gaps.

Start with linear regression or the Statistics course, depending on which worked answers were difficult. Check the Machine Learning syllabus for available lessons. A free account adds quizzes and progress. Pro adds practice for every lesson, projects, certificates and weekly live sessions with Gaurav.

References

For the validation designs behind the split question, see scikit-learn's official cross-validation guide. The prompts, datasets and worked arithmetic are original practice material.

Related course

Classical machine learning, completely: regression and gradient descent, classifiers and evaluation, trees and ensembles, clustering, dimensionality reduction, and putting models into production.

Open lessons' parts and key terms are free to read, with no account.

What you will be able to do

  • Build regression and classification models from scratch.
  • Understand the calculus and optimisation behind how models learn.
  • Evaluate models properly and spot overfitting.
  • Use trees, ensembles and clustering on real data.