Interview Q&A / Machine Learning
Machine Learning interview questions
Supervised vs unsupervised learning, overfitting, metrics and the classic models, explained simply.
Prefer rapid revision? Practise Machine Learning short interview answers →
- What are precision, recall and F1 score, and why can accuracy be misleading?
Precision is how many predicted positives were actually positive. Recall is how many actual positives the model found. F1 is their harmonic mean. On imbalanced data, a model can get high accuracy by always predicting the majority class while missing every case you care about.
BeginnerIn-depth4 min read - What is gradient descent, and what happens if the learning rate is too high or too low?
Gradient descent trains a model by repeatedly nudging its weights in the direction that reduces the loss fastest, which is opposite to the gradient. The learning rate sets the step size. Too small and training is very slow; too large and it overshoots the minimum and can bounce around or diverge.
BeginnerIn-depth4 min read - What is overfitting and underfitting, and what is the bias-variance trade-off?
Overfitting means the model memorises the training data, including noise, so it does well in training but badly on new data. Underfitting means the model is too simple to learn the pattern at all. The bias-variance trade-off is the balance between these two errors.
BeginnerIn-depth4 min read - What is the difference between linear regression and logistic regression?
Linear regression predicts a continuous number, like a house price, by fitting a straight line. Logistic regression predicts the probability of a class, like spam or not spam, by passing a linear score through the sigmoid function so the output stays between 0 and 1.
BeginnerIn-depth4 min read - What is the difference between supervised, unsupervised and reinforcement learning?
Supervised learning trains on examples that come with the correct answer (labels). Unsupervised learning finds patterns in data with no labels, such as groups. Reinforcement learning trains an agent by trial and error, using rewards and penalties from an environment.
BeginnerIn-depth4 min read - How does a decision tree work, and why does a random forest usually perform better?
A decision tree splits data with a series of yes/no questions, choosing each split to make the groups as pure as possible. A single deep tree overfits easily. A random forest trains many trees on random samples of rows and features and averages their votes, which reduces variance and usually improves accuracy.
IntermediateIn-depth4 min read - Why do we split data into train, validation and test sets, and what is k-fold cross-validation?
The training set teaches the model, the validation set is used to choose settings, and the test set is kept untouched for a final, honest score. K-fold cross-validation splits data into k parts and trains k times, each time testing on a different part, giving a more reliable estimate when data is limited.
IntermediateIn-depth4 min read - What is the difference between L1 and L2 regularisation?
Both add a penalty on weight size to the loss to reduce overfitting. L1 (Lasso) adds the sum of absolute weights and pushes many weights to exactly zero, so it also selects features. L2 (Ridge) adds the sum of squared weights and shrinks all weights smoothly towards zero without removing them.
AdvancedIn-depth5 min read