Tech

Machine Learning

Machine learning is the discipline of building systems that learn patterns from data and improve their performance without being explicitly programmed for every scenario. It underpins recommendation engines, fraud detection, autonomous vehicles, medical diagnosis, natural language processing, and predictive analytics across virtually every industry. Interviews typically test your understanding of supervised, unsupervised, and reinforcement learning paradigms; model selection and evaluation; the bias-variance tradeoff; regularization techniques; feature engineering; and how to deploy, monitor, and maintain models in production. Strong candidates connect theoretical concepts like gradient descent and cross-validation to practical decisions about data quality, model interpretability, scalability, and business impact.

What you get

Questions

20

Difficulty

3 levels

Answer Formats

2

Use the toggle on each card to move between an interview-ready answer and a simpler explanation. Questions are sorted from beginner to advanced, and the keywords are highlighted. You can also blur the answers to practice recalling them from memory.

Questions

Practice the answers out loud.

All topics

Question 1

What is overfitting, and how do you reduce it?

Beginner

How to answer in an interview

Overfitting happens when a model learns the training data too well, including noise and accidental patterns, so it performs well on training data but poorly on new data. I reduce it by collecting more data, simplifying the model, using regularization, applying early stopping, tuning hyperparameters on validation data, and checking performance on a truly untouched test set. The real goal is generalization, not memorization.

Question 2

Why do we split data into train, validation, and test sets?

Beginner

How to answer in an interview

We split data so each part has a different role. The training set teaches the model. The validation set helps choose models, features, and hyperparameters. The test set is reserved for a final unbiased estimate of performance after all decisions are made. This separation helps prevent data leakage and gives us a more realistic view of how the model will behave on new data.

Question 3

What is cross-validation and why is it important?

Beginner

How to answer in an interview

Cross-validation is a technique for estimating how well a model generalizes by splitting the data into multiple folds, training on some folds, and evaluating on the remaining fold. K-fold cross-validation repeats this process k times so every data point serves as both training and validation data. It gives a more robust estimate of performance than a single train-validation split, especially when data is limited. I use it for model selection, hyperparameter tuning, and detecting overfitting before committing to a final evaluation on the held-out test set.

Question 4

How do decision trees work and what are their limitations?

Beginner

How to answer in an interview

Decision trees work by recursively splitting the data on feature values that best separate the target classes or reduce prediction error. Common splitting criteria include Gini impurity, entropy, and mean squared error. They are easy to interpret and handle mixed data types, but they are prone to overfitting, sensitive to small changes in data, and can create overly complex trees. In practice, single decision trees are rarely used alone; instead, ensemble methods like random forests and gradient boosting combine many trees to reduce variance and improve accuracy.

Question 5

What is a neural network and what are its core components?

Beginner

How to answer in an interview

A neural network is a computational model inspired by the brain, made up of layers of interconnected nodes or neurons. Each neuron applies a weighted sum of its inputs, adds a bias, and passes the result through an activation function like ReLU, sigmoid, or softmax. The network learns by adjusting weights through backpropagation and gradient descent to minimize a loss function. Common architectures include fully connected networks, convolutional networks for images, and recurrent or transformer networks for sequences. The depth and width of the network determine its capacity to learn complex patterns.

Question 6

What is the difference between parametric and non-parametric models?

Beginner

How to answer in an interview

Parametric models assume a fixed functional form with a finite number of parameters that are learned from data, such as linear regression or logistic regression. They are simple, interpretable, and fast to train, but they may underfit if the true relationship is complex. Non-parametric models make fewer assumptions about the underlying form and can adapt their complexity to the data, such as k-nearest neighbors, decision trees, and kernel methods. They are more flexible but often require more data and computation. The choice depends on the amount of data, the complexity of the relationship, and the need for interpretability.

Question 7

When should you use precision instead of recall?

Intermediate

How to answer in an interview

I care more about precision when false positives are expensive, because I want the model to be very reliable when it predicts a positive. I care more about recall when missing true positives is worse than raising some extra false alarms. For example, fraud blocking and medical screening often have different trade-offs. The best metric depends on the business cost of false positives versus false negatives, and I usually pair the metric choice with a threshold analysis.

Question 8

What is gradient descent?

Intermediate

How to answer in an interview

Gradient descent is an optimization method that updates model parameters step by step to reduce a loss function. It follows the direction of steepest decrease, using the gradient to decide how to move. The learning rate controls how large each step is; if it is too small, learning is slow, and if it is too large, training can overshoot or diverge. Variants like stochastic gradient descent and mini-batch training are commonly used because they scale better to large datasets.

Question 9

How do you explain feature engineering?

Intermediate

How to answer in an interview

Feature engineering is the process of turning raw data into inputs that are more useful for a model. That can include encoding categories, scaling numbers, extracting date parts, creating ratios or interactions, and cleaning noisy values. Good feature engineering often improves model quality more than simply choosing a more complex algorithm, because the model can only learn from the signal you give it. Domain knowledge matters because it helps identify which transformations reflect the real problem.

Question 10

What is a random forest and how does it improve on a single decision tree?

Intermediate

How to answer in an interview

A random forest builds many decision trees on random subsets of the data and random subsets of features, then combines their predictions through averaging or majority voting. This approach reduces overfitting compared to a single tree by introducing diversity among trees. The randomness in both data sampling and feature selection prevents the ensemble from relying too heavily on any one feature or pattern. Random forests are robust, require relatively little tuning, handle high-dimensional data well, and provide feature importance scores that aid interpretability.

Question 11

What is gradient boosting and how does it differ from random forests?

Intermediate

How to answer in an interview

Gradient boosting builds trees sequentially, where each new tree focuses on correcting the errors made by the previous trees. It minimizes a loss function by adding weak learners that predict the negative gradient of the error. Unlike random forests, which build trees independently and reduce variance, boosting reduces bias by iteratively improving on hard examples. Popular implementations include XGBoost, LightGBM, and CatBoost. Gradient boosting often achieves higher accuracy than random forests but requires more careful tuning and is more prone to overfitting without regularization.

Question 12

What is regularization and what types are commonly used?

Intermediate

How to answer in an interview

Regularization adds constraints or penalties to a model to reduce overfitting and improve generalization. L1 regularization adds a penalty proportional to the absolute value of weights, which encourages sparsity and can perform feature selection. L2 regularization adds a penalty proportional to the squared weights, which shrinks coefficients but keeps them non-zero. Dropout randomly deactivates neurons during training, forcing the network to learn redundant representations. Early stopping is another form of regularization that halts training before the model memorizes the training data. The right choice depends on the model architecture and the nature of the data.

Question 13

How do you handle imbalanced datasets?

Intermediate

How to answer in an interview

Imbalanced datasets occur when one class is much rarer than others, which is common in fraud detection, medical diagnosis, and anomaly detection. I handle this through resampling techniques like oversampling the minority class, undersampling the majority class, or synthetic data generation with SMOTE. I also use appropriate metrics like precision, recall, F1, or AUC-PR instead of accuracy. Cost-sensitive learning assigns higher penalties to misclassifying the minority class. In extreme cases, I use anomaly detection approaches that do not assume balanced class distributions.

Question 14

What is batch normalization and why is it used?

Intermediate

How to answer in an interview

Batch normalization normalizes the activations of a layer within each training mini-batch, typically by centering them around zero and scaling to unit variance. It reduces internal covariate shift, which stabilizes training and allows higher learning rates. Batch normalization acts as a mild regularizer, smooths the loss landscape, and often accelerates convergence. During inference, it uses running averages learned during training. I use it in deep networks where training is unstable or slow, though layer normalization is sometimes preferred in recurrent or transformer architectures.

Question 15

What is the difference between L1 and L2 regularization?

Intermediate

How to answer in an interview

L1 regularization adds the sum of absolute weights to the loss function, which can drive some weights exactly to zero, effectively performing feature selection. L2 regularization adds the sum of squared weights, which shrinks weights toward zero but rarely makes them exactly zero. L1 produces sparse models and is useful when many features are irrelevant. L2 produces smoother models and handles correlated features better. Elastic net combines both. In practice, I use L1 when I want a simpler, interpretable model and L2 when I want to prevent any single feature from dominating.

Question 16

What is a support vector machine (SVM) and when would you use one?

Intermediate

How to answer in an interview

A support vector machine finds the optimal hyperplane that maximizes the margin between classes in a high-dimensional feature space. It is particularly effective for high-dimensional data and cases where the number of features exceeds the number of samples. The kernel trick allows SVMs to model non-linear decision boundaries by implicitly mapping data into higher dimensions without computing the transformation explicitly. SVMs are strong when margins are clear and data is not extremely noisy. They are less practical for very large datasets due to quadratic training complexity, but they remain valuable for text classification, bioinformatics, and other high-dimensional problems.

Question 17

What is dimensionality reduction and what methods are commonly used?

Intermediate

How to answer in an interview

Dimensionality reduction transforms high-dimensional data into a lower-dimensional representation while preserving as much relevant structure as possible. PCA finds orthogonal directions of maximum variance and projects data onto them. t-SNE and UMAP are non-linear methods that preserve local neighborhood structure, useful for visualization. Feature selection methods like mutual information or L1-based selection remove irrelevant features entirely. Reducing dimensions improves computational efficiency, reduces overfitting, and helps visualization. The choice between linear and non-linear methods depends on the complexity of the data structure.

Question 18

What is the bias-variance tradeoff?

Advanced

How to answer in an interview

Bias is error from making assumptions that are too simple, which can cause underfitting. Variance is error from a model changing too much based on the training data, which can cause overfitting. The tradeoff is that more flexible models usually reduce bias but increase variance, while simpler models do the opposite. In practice, I manage this tradeoff with model choice, regularization, feature engineering, cross-validation, and enough high-quality data.

Question 19

How do you deploy a machine learning model to production?

Advanced

How to answer in an interview

Deploying a machine learning model involves packaging the model into a serving infrastructure that can handle real-time or batch predictions reliably. I typically containerize the model, expose it through a REST or gRPC endpoint, and set up load balancing and auto-scaling. I establish CI/CD pipelines that retrain and validate models automatically. Monitoring is critical: I track prediction distributions, latency, error rates, and data drift. I maintain rollback capability and shadow deployments for safe rollouts. The key is treating the model as a software artifact with versioning, testing, and operational rigor.

Question 20

What is A/B testing for machine learning models and how do you analyze results?

Advanced

How to answer in an interview

A/B testing for ML models involves randomly assigning users to either the current model or a new candidate model and comparing their performance on real-world metrics. I define a hypothesis, choose a primary metric, calculate the required sample size for statistical power, and run the experiment for a sufficient duration to capture weekly patterns. I analyze results using statistical tests to determine significance, check for novelty effects and sample ratio mismatch, and examine segment-level effects. The goal is to establish a causal link between the model change and the business outcome, not just correlation.

More in Tech

Keep browsing related topics.

Browse all