Machine Learning Interview Questions for Freshers With Answers
Quick answer
Fifteen machine learning interview questions for freshers with concise answers, a worked precision and recall example and a leakage-safe code sample.
Machine learning interview questions for freshers focus on a short list of ideas: supervised versus unsupervised learning, overfitting and the bias-variance trade-off, how to validate a model, which metric fits which problem, and how common algorithms such as linear regression, decision trees and random forests work. Interviewers care more about your reasoning on a small example than about memorised formulas.
Key takeaways
- Around a dozen concepts cover most fresher rounds. Learn each with one example you can work out on paper.
- Accuracy is the answer interviewers hope you will not give for imbalanced data. Know precision, recall and F1 with numbers.
- Data leakage is a favourite follow-up. The safe habit is to fit preprocessing inside a pipeline, on training folds only.
- For every algorithm, prepare three lines: how it learns, when it fails, how you would tune it.
On this page:
- Which machine learning questions are asked most?
- How do you answer the core concept questions?
- How do you answer metric questions with numbers?
- What do interviewers ask about validation and leakage?
- Which algorithm questions should you prepare?
- How do you handle the practical or project round?
- Frequently asked questions
Which machine learning questions are asked most?
The same questions return in different wording, and each has a common wrong answer. This table pairs the question with the trap and the stronger response.
| Question | Common weak answer | What to say instead |
|---|---|---|
| What is overfitting? | "The model is too accurate" | It memorises training data and fails on new data. Mention how you would detect it. |
| Which metric would you use? | "Accuracy" | Ask about class balance and the cost of each error type, then choose. |
| Why split data? | "To test the model" | To estimate performance on unseen data. Separate validation for tuning from the final test. |
| Random forest vs decision tree? | "Forest is better" | Averaging many decorrelated trees reduces variance, at the cost of interpretability. |
| Why scale features? | "Always scale" | Needed for distance-based and gradient-based models. Tree models do not need it. |
| What is regularisation? | "It removes overfitting" | It adds a penalty on large weights. L1 can zero out features, L2 shrinks them. |
How do you answer the core concept questions?
Give a one-sentence definition, then an example from everyday data. Here are the five that open most interviews.
1. Supervised vs unsupervised learning?
Supervised learning trains on labelled examples: predicting a flat's price from its area and locality, where past prices are known. Unsupervised learning finds structure without labels: grouping customers of a kirana delivery app by buying pattern.
2. Classification vs regression?
Classification predicts a category (loan default: yes or no). Regression predicts a number (expected monthly electricity bill).
3. What is overfitting and how do you spot it?
Google's Machine Learning Crash Course describes an overfit model as one that matches the training set so closely that it fails to make correct predictions on new data. You spot it when training loss keeps falling while validation loss rises. Fixes: more data, a simpler model, regularisation, early stopping.
4. Explain the bias-variance trade-off.
Bias is error from a model too simple to capture the pattern (a straight line through curved data). Variance is error from a model that changes too much with the training sample (a very deep tree). Reducing one tends to raise the other, so you look for the complexity with the lowest validation error.
5. Parameters vs hyperparameters?
Parameters are learned from data, such as the weights in linear regression. Hyperparameters are set before training, such as tree depth or learning rate, and are tuned on validation data.
If the terms AI, ML and deep learning still blur together, clear that up first with this comparison of AI, machine learning and deep learning.
How do you answer metric questions with numbers?
Work a confusion matrix aloud. It takes ninety seconds and proves you understand the metric instead of reciting it.
6. A fraud model has 97% accuracy. Is it good?
Illustrative data: 1,000 transactions, 50 of them fraud. The model flags 60 transactions, and 40 of those are real fraud.
- True positives = 40, false positives = 20, false negatives = 10, true negatives = 930.
- Accuracy = (40 + 930) / 1,000 = 97%.
- Precision = 40 / (40 + 20) = 66.7%.
- Recall = 40 / (40 + 10) = 80%.
- F1 = 2 x 40 / (2 x 40 + 20 + 10) = 0.727.
Now the punchline: a model that flags nothing scores 95% accuracy on this data and catches zero fraud. The formulas above follow the definitions in Google's guide to accuracy, precision and recall, which also notes that accuracy can mislead on imbalanced datasets.
7. When do you prefer recall over precision?
When missing a positive is costlier than a false alarm: disease screening, fraud. Prefer precision when false alarms are costly: marking a genuine email as spam.
8. What is ROC-AUC?
The ROC curve plots true positive rate against false positive rate across all thresholds. AUC summarises it: 0.5 is random ranking, 1.0 is perfect. It tells you how well the model ranks positives above negatives, independent of one threshold.
What do interviewers ask about validation and leakage?
They ask how you know your score is honest. The scikit-learn documentation states the principle plainly: learning the parameters of a prediction function and testing it on the same data is a methodological mistake.
9. What is k-fold cross-validation?
Split the data into k folds, train on k-1, test on the remaining fold, repeat k times and average the scores. Stratified k-fold keeps the class ratio roughly the same in every fold, which matters for imbalanced labels.
10. What is data leakage? Show how you avoid it.
Leakage is when information from outside the training data influences the model, so the score looks better than it will be in real use. A classic case is scaling the full dataset before splitting. Put preprocessing in a pipeline so it is fitted on each training fold only:
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import StratifiedKFold, cross_val_score
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
X, y = load_iris(return_X_y=True)
model = make_pipeline(StandardScaler(), LogisticRegression(max_iter=200))
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
scores = cross_val_score(model, X, y, cv=cv)
print(scores.round(3), round(scores.mean(), 3))
# [1. 0.967 0.9 1. 0.9 ] 0.953 (scikit-learn 1.6; may differ slightly by version)
Be ready for the follow-up: "Why not tune hyperparameters on the test set?" Because knowledge of the test set leaks into your choices, and the final number stops measuring generalisation.
Which algorithm questions should you prepare?
Prepare the handful below with a "how it learns, when it fails" answer for each.
11. How does linear regression learn?
It finds the weights that minimise the sum of squared differences between predictions and actual values. It struggles when the relationship is non-linear or when outliers dominate the squared error.
12. Why is logistic regression a classifier?
It passes a linear combination of features through the sigmoid function to get a probability between 0 and 1, then applies a threshold. The name comes from the logistic function.
13. How does a decision tree choose a split?
It tries candidate splits and picks the one that most reduces impurity, measured by Gini or entropy for classification and variance for regression. Deep trees overfit easily.
14. Bagging vs boosting?
Bagging trains models independently on bootstrap samples and averages them. A random forest adds a random subset of features at each split, and the scikit-learn ensemble guide explains that these two sources of randomness exist to decrease the variance of the forest. Boosting trains shallow trees in sequence, each one correcting the errors of the ones before.
15. How does k-means work, and what is its weakness?
Pick k centres, assign each point to the nearest centre, move each centre to the mean of its points, repeat until assignments stop changing. You must choose k yourself, and results depend on the starting centres and on feature scale.
Several of these answers lean on probability and linear algebra. If that feels shaky, see which maths to learn for machine learning and the primer on statistics for data science.
How do you handle the practical or project round?
Describe your project as a sequence of decisions. A fresher who explains why they chose a metric is more convincing than one with a higher score and no reasons.
- Problem and data: what you predicted, how many rows, where labels came from.
- Baseline: the simplest model or rule you compared against.
- Validation: your split or cross-validation scheme and why.
- Metric: which one and what error it protects against.
- What failed: one thing you tried that did not help.
Need a project to talk about? Pick one from these machine learning project ideas for beginners, and read about entry-level machine learning jobs in India to see what roles expect.
Next step: answer the 15 questions aloud, then rework question 6 with your own numbers. If you want a guided start, the Certification in AI & ML (Launchpad) from Vishlesan i-Hub, IIT Patna is a 12-week programme for beginners.
Frequently asked questions
What machine learning topics should a fresher prepare for interviews?
Supervised and unsupervised learning, overfitting, bias and variance, train-validation-test splits, cross-validation, evaluation metrics, regularisation, and the working of linear and logistic regression, decision trees, random forests and k-means. Add one project you can explain in detail.
Is coding asked in machine learning interviews for freshers?
Usually yes. Expect Python basics, NumPy or pandas operations, and sometimes writing a simple model pipeline with scikit-learn. Some companies also ask general data-structure problems, so check the format with the recruiter.
How much maths is needed for a machine learning interview?
For fresher roles, you need working knowledge of probability, mean and variance, vectors and matrices, and the idea of a gradient. You should explain gradient descent in words. Derivations are more common in research-oriented roles.
How do I explain overfitting in an interview?
Say the model has learned the training data too closely, including its noise, so it performs well on training data and poorly on new data. Then add how you detect it, with a gap between training and validation scores, and two ways to reduce it.
Which is more important for ML interviews, projects or theory?
Both are tested, and they support each other. Theory questions check that you understand why methods work. Project questions check that you have applied them. A small project with clear validation and a justified metric usually carries the conversation.