Machine Learning Interview Questions and Answers

Supervised and unsupervised learning, evaluation, overfitting and MLOps.

Practise 10 random 3 peer-reviewed questions
Machine Learning Interview Syllabus & Preparation Strategy

Whether you are preparing for entry-level Machine Learning interview questions for freshers or senior software engineer interview questions addressing concurrency, scalability, and system architecture, this track provides peer-reviewed model answers with syntax walkthroughs, edge cases, and practical interview tips.

1 What is data leakage in machine learning? Hard

Data leakage is when information unavailable at prediction time seeps into training, producing optimistic validation scores that collapse in production.

Common sources:

  • Target leakage: a feature that is a proxy for the label, such as account_closed_date when predicting churn.
  • Train-test contamination: fitting scalers, imputers, target encoders or SMOTE on the full dataset before splitting.
  • Temporal leakage: using future data to predict the past, as with random splitting of time series.
  • Group leakage: the same entity appears in both train and test.

Prevention:

  • Split first, then fit all preprocessing on training folds only, ideally inside a pipeline.
  • Use time-based splits for temporal problems.
  • Audit features for whether they are known at prediction time.
  • Use grouped splits when rows share an entity.
Pipeline([("scaler", StandardScaler()), ("clf", LogisticRegression())])

Leakage often shows as suspiciously high accuracy, so treat such results with suspicion.

2 Explain ROC-AUC and when it can be misleading. Hard

ROC-AUC is the probability that a randomly chosen positive example is ranked above a randomly chosen negative one. It summarizes performance across all thresholds, and 0.5 is random.

from sklearn.metrics import roc_auc_score
roc_auc_score(y_true, y_scores)

Misleading cases:

  • Heavy class imbalance: ROC-AUC can look strong while precision is terrible, because the large negative class dominates the false-positive rate. Precision-recall AUC is more informative when the positive class is rare.
  • Threshold independence: AUC says nothing about the operating point you will deploy.
  • Calibration: a model can rank well but produce badly calibrated probabilities, which matters when decisions depend on the probability value.
  • Ranking versus cost: if errors have asymmetric costs, AUC ignores them.

Report AUC alongside PR-AUC, calibration curves and the confusion matrix at the chosen threshold.

3 How would you design a recommendation system end to end? Hard

Start with the objective and data: implicit signals such as views, clicks and purchases, plus explicit ratings and item or user features.

A common two-stage design:

  • Candidate generation: retrieve a few hundred relevant items quickly. Use collaborative filtering such as matrix factorization or ALS, content-based similarity, or approximate nearest neighbour search over embeddings. This scales to millions of items.
  • Ranking: score candidates with a richer model, gradient boosting or a neural network, using user, item and context features to optimize the target event.
user_vec = als_model.user_factors[user_id]
scores = item_factors @ user_vec
candidates = np.argpartition(scores, -200)[-200:]

Add business rules for diversity, freshness and filtering. Evaluate offline with recall@k and NDCG, then run online A/B tests on engagement and revenue. Address the cold start problem with popularity or content features, and monitor feedback loops and drift.

Frequently Asked Questions About Machine Learning Interviews

What do hiring managers evaluate in Machine Learning technical rounds?

Technical interviewers look for foundational fluency, idiomatic syntax, clarity when communicating complex logic, and awareness of performance trade-offs (e.g. memory footprint, render performance, and network latency) in production environments.

What are the best interview tips for practicing Machine Learning questions?

Use active recall: summarize each answer in your own words before revealing the model solution. Focus on explaining why a certain approach is chosen rather than just memorizing code syntax.