Machine Learning Interviews
The 77 machine learning (ML) topics that come up most in internship and job interviews, from exploratory analysis to neural networks and ML operations (MLOps): what to study, how to study it and how to answer. With short answers, a quiz, a checklist to track your progress and, for every topic, a link to the class where it is taught.
The 2 p.m. question
A scene that is going to happen to you.
Thursday, 2 p.m. An interview for the internship you wanted most, on a data team. After the introductions, the interviewer turns her laptop toward you: a churn model (customers who cancel), trained by someone on the team, with 95% accuracy on the test set. And she asks, with nothing else:
"Is this model any good?"
She does not want a yes or a no. She wants to see how you think.
There is a weak answer ("yes, 95% is very high") and a strong one, which starts with a question back: "what is the churn rate?". If only 5% of customers cancel, a model that never predicts a cancellation already scores 95% accuracy without having learned anything.
The difference between the two answers is not memorizing more definitions. It is knowing how to connect what you have learned: baselines, class imbalance and the confusion matrix, thresholds and the cost of errors. This page lays out that path. At the end, we come back to the 2 p.m. question with the full answer.
What an ML interview looks like
Three kinds of question, three skills, one logic: reasoning about data out loud.
"What is overfitting?"
Tests whether you can define it in your own words, give the intuition and say when the idea breaks down. There is almost always an "it depends" hiding in it.
"Training 0.99, validation 0.72"
Tests diagnosis and next steps. There is no single answer: there is structured reasoning and justified choices.
"Build this pipeline"
Tests whether you use scikit-learn without leaking: Pipeline, ColumnTransformer, cross_val_score.
For an entry-level role, almost nobody expects you to know the newest algorithm. What sinks candidates are the basic traps: comparing without a baseline, reporting accuracy on imbalanced data, fitting transformations before splitting the data, choosing hyperparameters by looking at the test set. Avoid those four and you are already ahead of most.
What the interviewer is assessing
| Aspect | Conceptual | Case | Coding |
|---|---|---|---|
| Right answer | One definition, with nuances | Several valid answers | Code that runs and does not leak |
| Focus | Clarity and intuition | Diagnosis and trade-offs | Using the tools correctly |
| Typical length | 1β3 min per question | 10β20 min | 15β30 min |
| Most common mistake | Reciting without the trap | Jumping to a model without asking for context | Preprocessing before the split |
| Where to practice | Key concepts | Case questions | The class labs, redone without notes |
How to answer
8 principles for turning what you know into an answer that convinces.
Practical tip: signpost your transitions. When you move from diagnosis to solution, say it out loud: "so the problem looks like variance; I'll suggest three ways to reduce it, from the cheapest to the most expensive". The interviewer follows your structure and you do not lose your way.
Case questions, step by step
"Walk me through how you would build a model toβ¦" β the most common open question. The answer is the ML workflow, a loop of six steps.
Pipeline with a ColumnTransformer, fitted on the training part of each fold only. The baseline (the mean or the majority class) sets the floor. D3 Β· Pipelines β Always ask: "what does it cost to be wrong in each direction?" It changes everything. If a false negative is expensive (an undetected patient, a fraud that slips through), you will favor recall and lower the threshold. If a false positive is expensive (blocking an honest customer), you will favor precision. The metric and the threshold come from that answer, not from the default of predict.
Quick diagnosis
The symptoms that show up in case questions, what they usually point to and what to do about them.
In case questions, the interviewer describes a symptom and expects a diagnosis with a next step. Before proposing a new model, rule out the cheap causes: leakage, a poorly chosen baseline, the wrong metric, feature scales, different distributions in training and validation.
| Symptom | Likely diagnosis | Next step |
|---|---|---|
| Training 0.99, validation 0.72 | Overfitting (high variance) | Rule out leakage; reduce complexity, regularize, get more data |
| Training and validation both poor | Underfitting (high bias) | A more flexible model or better features; more data will not help |
| 95% accuracy on a rare-event problem | Possibly just the majority class | Compare with the baseline; look at recall, precision, PR-AUC (area under the precisionβrecall curve) |
| One feature alone gives an AUC (area under the ROC, receiver operating characteristic, curve) of 0.99 | Target leakage | Check when the feature is recorded; remove it and measure the drop |
| Model B beats A by 0.004 | A difference within the noise | Look at the spread across folds; prefer the simpler one |
| Great on validation, much worse on test | Overfitting the validation set through tuning, or a leaky split | Nested CV (nested cross-validation); a temporal or grouped split; a test set truly locked away |
| Coefficients with absurd signs | Multicollinearity | Do not read them one by one; regularize (ridge); drop redundant features |
| U-shaped pattern in the residuals | A nonlinear relationship the model misses | Transform features, add terms, use a nonlinear model |
| The k-means clusters follow a single column | Features on different scales: the one with the largest unit dominates the distance | Standardize inside the pipeline; decide scaling from the units, not from the silhouette |
| The training loss oscillates or blows up | Learning rate too large (or unscaled features) | Lower the learning rate; standardize the inputs |
| Great on validation, poor from day one in production | Trainingβserving skew, or a feature that does not exist at prediction time | Compare how features are computed in training and in serving; validate inputs against a schema |
| In production, slowly gets worse with no code change | Drift: the inputs or their relationship with the target changed | Monitor features and scores (PSI, the population stability index; the KolmogorovβSmirnov or KS test); measure when the labels arrive; retrain on recent data |
"Training 0.99, validation 0.72"
Ask: which model, how much data, how was the split done?
Rule out the cheap causes: does any feature exist only after the target? Are rows from the same customer on both sides? Do training and validation come from the same distribution?
Diagnose: a 0.27 gap means high variance: the model memorized the training set.
Propose, cheapest first: limit the depth or regularize; drop noisy features; collect more data, if the learning curve shows it would help. Show a validation curve to choose the complexity.
What to use when
Validation curve: choose the complexity (depth, regularization) from the U of the error.
Learning curve: find out whether more data is worth it.
Cross-validation: estimate performance and its variability with less split luck.
Confusion matrix: see what kind of errors the model makes, not just how many.
Permutation importance and SHAP (SHapley Additive exPlanations): learn which features the model uses on new data, and for each prediction.
Shuffled data: the yardstick for any clustering and any suspicious score.
PSI and the KS test: detect that the inputs have changed in production.
The 77 key concepts
The 77 topics, in eight themes. Try answering out loud before opening each theme. The numbers identify each topic in the checklist; the code next to each question takes you to the class where the topic is taught.
DummyRegressor and DummyClassifier. It sets the floor: a model that does not beat the baseline is useless, however sophisticated it is.Pipeline guarantees that fit sees only the training part of each fold, and applies exactly the same steps at prediction time.handle_unknown="ignore".FunctionTransformer or a transformer of your own. Trap: aggregates computed with the test set are leakage.TimeSeriesSplit). A random split lets the model "see the future": in class, a series that cannot be predicted by construction (a random walk) scored RΒ² = 0.99 with shuffled KFold and β1.78 with TimeSeriesSplit.StratifiedKFold, stratify=y). Essential with rare classes or small samples.GroupKFold. Otherwise the model recognizes the patient, not the disease: in class, shuffled KFold reported 93.8% and GroupKFold 78.0%, close to the 75.45% on new patients. Guiding question: what unit will the model predict on in production? That is the unit of the split.n_init well above 1) and on the column scales; and it always returns \(k\) clusters, even on pure noise.predict for new points.transform for new data, and preserves the global structure. t-SNE (t-distributed stochastic neighbor embedding) and UMAP (uniform manifold approximation and projection) are nonlinear and preserve neighborhoods: great for visualization. Trap: on a t-SNE or UMAP map, cluster sizes, the distances between clusters and the axes mean nothing; the map is a hypothesis, not a result, and it is not a feature for a classifier.fit). TF-IDF (term frequencyβinverse document frequency) multiplies the count by a weight that falls for words present in many documents: specific words count more. Trap: word order is lost ("the dog bit the man" and "the man bit the dog" become the same vector) and the matrix is huge and sparse.TfidfVectorizer default), cosine is just the dot product.In the formulas, \(y\) is the true value and \(\hat y\) the prediction; SSres is the sum of the squared residuals \(y - \hat y\) and SStot the sum of the squares of \(y\) around its mean.
TP, FP, FN and TN: true positives, false positives, false negatives and true negatives (the four cells of the confusion matrix, topic [44]).
[[TP, FN], [FP, TN]] (confusion_matrix(y, p, labels=[1, 0])). TP and TN are the hits; FP, the false alarms; FN, the missed positives. Every threshold-based metric comes from it; know how to compute them by hand.class_weight solves the problem with less risk.class_weight gives the minority's errors more weight in the loss; undersampling drops majority examples (fast, loses information); oversampling duplicates or synthesizes minority ones (uses everything, risks overfitting). The last two on the training data only. Trap: all of them distort the predicted probabilities; for logistic regression, class_weight is almost the same as moving the threshold.predict.alpha), early stopping (hold out part of the training data and stop when its score stops improving), dropout (switch off random units at each step), fewer units and more data. And standardize the inputs.alpha. On images, audio and text the balance tips toward networks.Quiz
Twenty-four interview-style questions, three per theme. Filter by theme to review only what you need.
Study plan
How to study, and a plan for the two weeks before an interview.
Out loud, to someone
If you cannot explain a concept to a classmate who missed the class, you have not learned it yet. Studying in pairs, one interviewing the other with the case questions, is the best practice there is.
Five lines from memory
Know how to write these without looking anything up: train_test_split, Pipeline, ColumnTransformer, cross_val_score, confusion_matrix, KMeans, TfidfVectorizer, permutation_importance. Redo the class labs until you can.
A day, a week, a month
Reviewing spaced out in time sticks far better than cramming the night before. Whatever you forget between rounds is what needs the most attention.
The checklist is your thermometer
Tick an item only when you can explain it without looking at anything, trap included. A checklist full of items ticked out of optimism will not help you in the interview.
| Days | What to do |
|---|---|
| 1β2 | Fundamentals and data: key concepts and the quiz for both themes; reread classes F2, D1 and D2 |
| 3β4 | Pipelines and leakage: build a leak-free pipeline from scratch without notes; explain the five leakage patterns of C5 |
| 5β6 | Regression and classification: metrics by hand from a list of residuals and from a confusion matrix; ridge vs lasso; k-NN |
| 7β8 | Validation, trees and ensembles: explain bias and variance and cross-validation by drawing; forest vs boosting; permutation importance and SHAP |
| 9 | Unsupervised learning and text: k-means by hand on six points, the silhouette, PCA; TF-IDF of three sentences and the cosine between them |
| 10 | SVM, networks and production: margin and kernel, activation and backpropagation, the three kinds of drift, out loud |
| 11β12 | Case questions in pairs, timed, with the quick diagnosis; the full quiz, going back only to what you got wrong |
| 13β14 | One final round of the whole checklist, out loud |
To practice in the course's format, and for the final assessment too: the workbook, with one activity per class, exercises at three levels and worked answers (in Portuguese). For a quick review: the cheat sheet, the concept map and the study cards.
Checklist
The 77 topics and the interview habits. Your progress is saved in your browser.
Back to 2 p.m.
The full answer to "is this model with 95% accuracy any good?"
Four steps, one minute and seven of the 77 topics in a single answer. That is what the interviewer wanted to see: not what you memorized, but how you connect it.
References
To go deeper, grouped by kind.