In this article
Foundations
What is machine learning, and how does it differ from AI?
Machine learning (ML) is a way of building programs that learn a rule from example data instead of having a person write the rule. Artificial intelligence (AI) is the wider goal of machines doing tasks that need intelligence, and ML is one method for reaching it, alongside hand-written rules and search. A spam filter trained on labeled emails is ML; a fixed list of banned words is not.
Why it is asked: it separates candidates who define terms precisely from those who use them as buzzwords. Read the full explanation: machine learning algorithms: types, how they work and how to choose.
What is overfitting, and how do you prevent it?
Overfitting is a model matching the training set so closely that it fails on new data (Google Machine Learning Crash Course, overfitting, accessed October 2026). It shows up as training and validation loss curves that diverge. The same source names unrepresentative data and overly complex models as common causes, so the fixes are more representative data, a simpler model, regularization or earlier stopping.
Why it is asked: every modeling decision is a fight against it. Read the full explanation: bias versus variance in machine learning.
What is the bias-variance tradeoff?
Bias is the error from a model too simple to capture the pattern; variance is the error from a model so sensitive to its training sample that small changes in the data change its output a lot. High bias underfits and high variance overfits. Making a model more flexible usually lowers bias and raises variance, so you tune complexity until validation error is lowest.
Why it is asked: it tests whether you can diagnose a model from its train and validation error. Read the full explanation: bias vs variance in machine learning.
What is gradient descent?
Gradient descent is a method that minimizes a loss by repeatedly moving the parameters a small step against the gradient, the direction in which the loss rises fastest. The learning rate sets the step size: too large and the loss bounces or diverges, too small and training crawls. Stochastic versions compute the gradient on one example or a small batch (mini-batch) to save time.
Why it is asked: nearly every trained model rests on it. Read the full explanation: what gradient descent is in machine learning.
What is the difference between L1 and L2 regularization?
Regularization adds a penalty on model weights to the loss, so the model cannot fit noise as freely. L2 penalizes the sum of squared weights and shrinks all of them smoothly. L1 penalizes the sum of absolute values and can push some weights to exactly zero, which acts as feature selection. You tune the penalty strength on validation data.
Why it is asked: it checks whether you know the effect of each penalty, not only its name. Read the full explanation: L1 vs L2 regularization.
Data splitting and leakage
How do you split data, and what is cross-validation?
A training set fits the model, a validation set chooses between models and settings, and a test set gives one final estimate. Cross-validation is a way to estimate performance by splitting the training data into folds, then rotating: train on all but one fold, score on the held-out fold, repeat until each fold has been held out once, and average the scores. The scikit-learn guide says test data should never be used to make choices about the model (scikit-learn 1.9.1, common pitfalls, accessed October 2026).
Why it is asked: an honest evaluation is the base of every later claim. Read the full explanation: the classical machine learning guide.
What is data leakage?
Data leakage is the use of information that would not be available at prediction time when building the model; it produces overly optimistic estimates, for example from cross-validation, and poorer performance in production (scikit-learn 1.9.1, accessed October 2026). It is not only test labels in training: a scaler, an imputer or principal component analysis (PCA) fitted on all the data leaks too. Learn transformations from training data only, use a Pipeline, and never call fit on test data.
Why it is asked: it is a classic reason a model scores well in testing and fails live. Read the full explanation: feature engineering for encoding, scaling and missing data.
How do you handle missing data?
First find out why values are missing, because random gaps and gaps that carry meaning, such as a field only some users skip, need different handling. Common options are dropping rows when few are affected, filling with the median or a model-based estimate, and adding an indicator column that marks the filled values. Fit the imputer on training data only, or it leaks.
Why it is asked: real data is messy, and the choice shows your judgment. Read the full explanation: feature engineering techniques.
Knowing it is half the job. Saying it is the other half.
Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.
Start Free Trial →Metrics and loss
When is accuracy misleading, and what are precision and recall?
Precision is the share of predicted positives that are truly positive; recall is the share of true positives the model finds. Accuracy, the share of all predictions that are right, misleads on imbalanced classes. In an illustrative set of 1,000 examples with 10 positives, a model that always says negative scores 0.99 accuracy and 0 recall.1
| Measure | Always says negative | Finds some positives |
|---|---|---|
| Accuracy | 0.99 | 0.982 |
| Precision | undefined (no positive predictions) | 0.3 |
| Recall | 0 | 0.6 |
| F1 (harmonic mean of precision and recall) | 0 (by convention, when precision is undefined) | 0.4 |
Why it is asked: it shows whether you choose a metric from the cost of each error. Read the full explanation: how to compute a receiver operating characteristic curve in scikit-learn.
How do you handle an imbalanced dataset?
Start with metrics that suit rare positives, such as precision, recall or a precision-recall curve, rather than accuracy. Then choose a remedy: resample the training data (oversample the rare class or undersample the common one), weight the classes in the loss, or move the decision threshold to match the cost of each error. Keep the test set at its real class ratio so the estimate stays honest.
Why it is asked: it is the natural follow-up to the accuracy question and shows whether you fix the metric before the model. Read the full explanation: the classical machine learning guide.
What are the receiver operating characteristic curve and AUC?
A receiver operating characteristic (ROC) curve plots the true positive rate against the false positive rate as you sweep the decision threshold. The area under the curve (AUC) summarizes it in one number: one half for a random ranking, one for a perfect ranking. It measures how well the model ranks positives above negatives, not which threshold to use, and on very imbalanced data a precision-recall view can be more informative.
Why it is asked: it tests threshold-free evaluation and its limits. For the plotting code, see the scikit-learn ROC example, accessed October 2026. Read the full explanation: how to compute and plot a ROC curve in scikit-learn.
What is cross-entropy loss?
Cross-entropy loss is the negative log of the probability a classifier gives to the correct class, averaged over examples. A confident wrong answer is punished heavily because the log of a tiny probability is a large negative number, while a confident right answer costs almost nothing. Minimizing it is the same as maximizing the likelihood of the labels.
Why it is asked: it links probability to the training objective. Read the full explanation: what cross-entropy loss is.
Algorithms and applications
What are the assumptions of linear regression?
Linear regression assumes the target is roughly a linear function of the features, that errors are independent, that error variance is constant (homoscedasticity), and that errors are roughly normal when you want valid confidence intervals. With several features, strongly correlated ones (multicollinearity) make coefficients unstable. Check residual plots rather than trusting the assumptions.
Why it is asked: it shows whether you know when the simplest model can be trusted. Read the full explanation: the assumptions of linear regression.
What is the difference between k-means and k-nearest neighbors?
The k-means method is unsupervised clustering that groups unlabeled points around k centers. The k-nearest neighbors method is supervised: it labels a new point by the labels of its k closest training points. The k means different things in each. Both depend on distance, so scale the features first.
Why it is asked: the similar names catch candidates who memorized terms without the idea. Read the full explanation: k-means versus k-nearest neighbors.
How do decision trees and random forests work?
A decision tree predicts by asking a series of yes-or-no questions about the features, splitting the data at each step so the groups become purer, until it reaches a leaf that holds the prediction. A single deep tree overfits. A random forest trains many trees, each on a random sample of the rows and a random subset of the features, and averages their votes, which lowers variance.
Why it is asked: it tests whether you can link a model's structure to overfitting and to the variance side of the tradeoff. Read the full explanation: the classical machine learning guide.
What is the difference between bagging and boosting?
Bagging trains many models independently on random resamples of the data and averages them, which mainly reduces variance; a random forest is bagging with trees. Boosting trains models one after another, each focusing on the errors of the earlier ones, which mainly reduces bias but can overfit noisy data. Gradient boosting fits each new tree to the error the ensemble still makes.
Why it is asked: ensembles are common in practice, and the question checks whether you know what each one fixes. Read the full explanation: the classical machine learning guide.
How do you choose which algorithm to use?
Start from the target and the data: a labeled number points to regression, a labeled category to classification, and no labels to clustering or anomaly detection. Then weigh data size, the need to explain results and training time. A strong answer starts with a simple baseline such as linear or logistic regression and moves to a complex model only when validation results justify it.
Why it is asked: it tests reasoning from a problem, not a list of algorithms. Read the full explanation: how to choose a machine learning algorithm.
What is collaborative filtering?
Collaborative filtering recommends items from the behavior of many users rather than item descriptions: if people who liked what you liked also liked an item, you are shown it. Its weak point is the cold start, when a new user or item has no history, usually handled by falling back on item content or popularity.
Why it is asked: recommendation is a common applied question, and the cold start is the follow-up. Read the full explanation: how collaborative filtering recommends.
What is the difference between exploration and exploitation?
Exploitation picks the option that looks best so far; exploration tries other options to learn whether something is better. Too much exploitation can lock in a mediocre choice, and too much exploration wastes opportunities. A simple rule, epsilon-greedy, explores at random a small fraction of the time. Recommendation and bandit problems depend on this balance.
Why it is asked: it checks whether you see learning as a decision problem. Read the full explanation: exploration vs exploitation.
How does anomaly detection work on a time series?
Anomaly detection on a time series flags points that break the pattern, so you first model what normal looks like, including trend and seasonality, then flag observations far from the expected value. A fixed threshold on the raw value fails when the series has a weekly cycle; compare each point with the expected value for that time instead.
Why it is asked: it tests handling of data where order matters. Read the full explanation: how anomaly detection works on a time series.
What is the difference between BLEU and ROUGE?
The bilingual evaluation understudy (BLEU) and recall-oriented understudy for gisting evaluation (ROUGE) metrics both score generated text against reference text by word overlap. BLEU leans on precision, asking how much of the generated text appears in the references, and is usually reported for translation. ROUGE leans on recall, asking how much of the reference is covered, and is usually reported for summarization. Neither captures meaning well, so pair them with human review.
Why it is asked: it checks whether you know what a metric rewards. Read the full explanation: BLEU vs ROUGE.
Production
What is distribution shift, and how do you detect it?
Distribution shift is when the data a model sees in production differs from the data it was trained on, so accuracy falls with no code change. Google's overfitting module lists examples that are independent, identically distributed and stationary as a condition for good generalization (Google Machine Learning Crash Course, accessed October 2026). Detect it by comparing live feature distributions with training ones and tracking metrics once labels arrive.
Why it is asked: it shows whether you think past the notebook. Read the full explanation: what distribution shift is and how to detect it.
Follow-up questions
How to prepare for machine learning interview?
Practice explaining each idea above in two or three sentences, then once with a small example, because interviewers follow a definition with a "why" or a "what if". Cover the statistics underneath in the statistics guide for ML and data roles, and rehearse the answers out loud.
What are machine learning interview questions for freshers and for experienced candidates?
For freshers, expect definitions and tradeoffs: overfitting, bias and variance, metrics, regularization. For experienced candidates, expect the same topics with production angles, such as leakage in a pipeline or distribution shift after launch. Reported practice differs by company, so treat this as advice, not a rule.
How do system design rounds for ML roles work?
A strong answer walks through the objective, the data, the metric, a baseline model, serving and monitoring, and names tradeoffs at each step. A strong answer ties the metric to the goal, uses realistic data and labels, starts from a simple baseline, and says how monitoring would catch drift. The bias and variance and leakage answers above are the checks you apply along the way.
Do machine learning interviews include coding?
Many loops include a coding round, so be ready to write short routines such as a metric or a split from scratch while explaining your reasoning. A worked gradient descent loop is a good one to rehearse.
- Overfitting is memorizing the training set; watch diverging training and validation curves.
- Learn every transformation from training data only, or the estimate leaks.
- Accuracy misleads on imbalanced classes; precision and recall show what it hides.
- Start from a simple baseline and justify each step up in complexity.
- A model can degrade in production with no code change when the data shifts.
Sources
- Common pitfalls and recommended practices, section 12.2 Data leakage (scikit-learn 1.9.1) — scikit-learn documentation, 26 Oct 2026
- Overfitting (Machine Learning Crash Course) — Google for Developers, 26 Oct 2026
- Receiver Operating Characteristic (ROC) (scikit-learn 1.9.1) — scikit-learn documentation, 26 Oct 2026