Key takeaways
- The one question you can count on is a deep dive into your own project: why that model, that metric and that validation.1
- Data leakage is the costliest mistake: information that won’t exist at prediction time makes validation scores over-optimistic. Pipelines prevent it.2
- Accuracy misleads on rare classes. Binary classifiers predict the positive class above a 0.5 probability by default, and scikit-learn 1.5 added TunedThresholdClassifierCV to tune it.3
- Code in old tutorials has changed: scikit-learn 1.8 deprecated LogisticRegression’s penalty (use
l1_ratio), and 1.9 deprecated SVC’s probability option.45 - Built-in tree importance is strongly biased toward high-cardinality features; permutation importance on held-out data is the safer answer.6
What ML rounds test
A fresher ML round checks that you understand the fundamentals well enough to choose, validate and explain a model, usually after an online test of aptitude, Python, SQL and ML multiple-choice questions. Most then probe one of your projects.
| Company type | What the rounds look like | Start with |
|---|---|---|
| IT services and analytics firms | An online test, then ML basics and your projects, increasingly with GenAI questions; a case at analytics firms | 1–14, 18, 36, 39, 40 |
| Product companies | Coding (DSA, SQL), sometimes a machine-graded ML notebook; then the maths behind models, statistics and a case | 6, 7, 16, 17, 24, 28, 32, 38 |
| GCCs | A written test, then one interview heavy on statistics and ML basics | 3–6, 13, 26, 28, 30, 31 |
| BFSI | An MCQ test; then projects, ML basics, guesstimates and fraud or banking cases | 9, 24, 25, 34, 36 |
| Startups | Two or three rounds, sometimes with the CTO: live coding, rapid-fire theory, open problems | 15, 20, 33, 35–37 |
From candidates’ interview write-ups for 2024–2026, most from campus placements, read 22 Oct 2026.1
Many rounds also test Python and SQL: see our Python interview questions and SQL interview questions.
The example data and model
The code uses one synthetic churn table for an Indian telecom: tenure, monthly charge in ₹, plan, city tier, complaints in the last 90 days, and whether the customer churned, which only a few per cent do. Run this first; it also builds the model the answers refer to.
import numpy as np
import pandas as pd
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler
rng = np.random.default_rng(42)
n = 5_000
df = pd.DataFrame({
"tenure_months": rng.integers(1, 73, n),
"monthly_charge": rng.normal(499, 150, n).round(),
"plan": rng.choice(["prepaid", "postpaid"], n, p=[0.7, 0.3]),
"city_tier": rng.choice(["tier 1", "tier 2", "tier 3"], n),
"complaints_90d": rng.poisson(0.4, n),
})
# churn is likelier with short tenure and more complaints
p = 1 / (1 + np.exp(2.3 + 0.03 * df["tenure_months"] - 0.9 * df["complaints_90d"]))
df["churned"] = (rng.random(n) < p).astype(int)
df.loc[rng.random(n) < 0.05, "monthly_charge"] = np.nan # 5% missing, as in real data
X, y = df.drop(columns="churned"), df["churned"]
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, stratify=y, random_state=42)
num_cols = ["tenure_months", "monthly_charge", "complaints_90d"]
cat_cols = ["plan", "city_tier"]
prep = ColumnTransformer([
("num", Pipeline([("impute", SimpleImputer(strategy="median")),
("scale", StandardScaler())]), num_cols),
("cat", OneHotEncoder(handle_unknown="ignore"), cat_cols),
])
model = Pipeline([("prep", prep),
("clf", LogisticRegression(class_weight="balanced"))])
model.fit(X_train, y_train)
Easy: 12 questions
The fundamentals online tests and first rounds check. Answer each in under a minute.
1. What is machine learning: supervised, unsupervised or reinforcement?Easy
Machine learning is building models that learn patterns from data instead of following hand-written rules. Supervised learning learns from labelled examples (churned or not); unsupervised learning finds structure without labels (customer segments); reinforcement learning learns actions from rewards (a game-playing agent).
2. Classification or regression?Easy
Classification predicts a category: will this customer churn, is this UPI payment fraud? Regression predicts a number: next month’s sales, a flat’s price. Some problems fit either (“will sales fall?” or “by how much?”), so ask how the answer will be used.
3. Why split data into training, validation and test sets?Easy
The model learns on the training set; you tune and choose models on validation data or by cross-validation; you check the final choice once on the test set. Make decisions on the test set and it stops being a fair estimate. train_test_split holds out 25% by default, and stratify keeps the class proportions, as in the code above.7
4. What are overfitting and underfitting?Easy
Overfitting: the model learns noise, so it scores far better on training data than on validation data. Underfitting: it misses the pattern, so both scores are poor. Fix overfitting with more data, a simpler model, regularisation or early stopping; fix underfitting with better features or a more flexible model.
5. Explain the bias–variance trade-offEasy
Bias is error from wrong assumptions, like a straight line through a curve. Variance is error from sensitivity to the particular training sample, like a deep tree that changes with every new sample. More flexibility lowers bias and raises variance; aim for the lowest error on unseen data, found by validation.
6. What does linear regression assume?Easy
A linear relationship between features and target, independent errors, constant error variance (homoscedasticity), no perfect multicollinearity, and, for p-values and confidence intervals, roughly normal errors. Check residual plots: a funnel means changing variance; a curve means the relationship isn’t linear.
7. Why is logistic regression called regression if it classifies?Easy
It models the log-odds of the positive class as a linear function of the features; the sigmoid turns that into a probability, and a threshold turns the probability into a class. It’s trained by minimising log loss, and scikit-learn applies L2 regularisation by default.4
8. What is a confusion matrix?Easy
A table of actual against predicted classes: true positives, false positives (false alarms), false negatives (misses) and true negatives. Every classification metric is built from it. In scikit-learn, rows are actual classes and columns predicted ones.8
from sklearn.metrics import confusion_matrix, classification_report
y_pred = model.predict(X_test)
tn, fp, fn, tp = confusion_matrix(y_test, y_pred).ravel()
print(classification_report(y_test, y_pred)) # precision, recall, F1 per class9. Accuracy, precision, recall or F1?Easy
Precision is TP / (TP + FP): of the cases you flagged, how many were right. Recall is TP / (TP + FN): of the real cases, how many you caught. F1 is their harmonic mean. Accuracy misleads with rare classes: if 2% of payments are fraud, a model that flags nothing is 98% accurate and useless.9
10. Why scale features, and which models need it?Easy
Models built on distances or gradients care about units: KNN, SVM, k-means, PCA and regularised linear models, where monthly charges in rupees would swamp tenure in months. Trees, random forests and boosting split on thresholds and don’t need scaling. Fit the scaler on training data only.
11. One-hot or label encoding?Easy
One-hot encoding makes a 0/1 column per category, for unordered categories such as plan or city tier. Label or ordinal encoding maps categories to integers: fine for ordered categories and for trees, but it invents an order for linear models. Set handle_unknown="ignore" so a new category in production gives all zeros instead of an error.10
12. How do you handle missing values?Easy
First ask why they’re missing: a blank income may mean “not disclosed”, which is information. Then drop, impute (median for numbers, most frequent for categories) or add a missing flag. In scikit-learn 1.9, HistGradientBoosting and RandomForest handle NaN natively.11
Medium: 16 questions
Validation, leakage, the main algorithms and the metrics: the core of most rounds.
13. What is cross-validation, and why stratified folds?Medium
k-fold cross-validation trains k times, each time holding out a different fold, and averages the scores, so one lucky split can’t mislead you. Stratified folds keep each fold’s class balance; for classifiers, cross_val_score uses them by default when cv is a number.12
from sklearn.model_selection import cross_val_score
scores = cross_val_score(model, X_train, y_train, cv=5, scoring="average_precision")
print(scores.mean(), scores.std())14. What is data leakage? Give examplesMedium
Using information at training time that won’t exist at prediction time, which makes scores over-optimistic. Classic cases: scaling or imputing the full dataset before splitting, a feature recorded after the outcome (“refund issued” when predicting returns), and random splits on time-ordered data. scikit-learn’s rule: never call fit on test data.2
15. Why put preprocessing and the model in one pipeline?Medium
A Pipeline learns the imputer, scaler and encoder from training data only, re-fits them inside every cross-validation fold, and runs the same steps at prediction time, so it prevents leakage and training–serving mismatches. ColumnTransformer sends numeric and text columns to different steps, as in the model above.2
16. L1 or L2 regularisation?Medium
Both penalise large coefficients to curb overfitting. L2 (Ridge) shrinks all of them smoothly; L1 (Lasso) can set some exactly to zero, so it also selects features; Elastic Net mixes both. In LogisticRegression, C is the inverse of regularisation strength, and since 1.8 you pick the type with l1_ratio.4
from sklearn.linear_model import Lasso, LogisticRegression, Ridge
Ridge(alpha=1.0) # L2, regression
Lasso(alpha=0.1) # L1, regression
LogisticRegression(C=0.5) # L2 by default (l1_ratio=0)
LogisticRegression(C=0.5, l1_ratio=1, solver="liblinear") # L1; "saga" also works17. How does a decision tree choose a split?Medium
At each node it tries features and thresholds and greedily picks the split that makes the child nodes purest, by Gini impurity (scikit-learn’s default) or entropy. With no depth limit, a tree grows until its leaves are pure and memorises the training data, so set max_depth or min_samples_leaf.13
18. Bagging or boosting?Medium
Bagging trains models independently on bootstrap samples and averages them, which mainly cuts variance: random forest. Boosting trains models in sequence, each correcting the errors of the ones before, which mainly cuts bias: gradient boosting and XGBoost.
19. How does a random forest reduce overfitting?Medium
Each tree sees a bootstrap sample of rows and, at each split, a random subset of features (by default the square root of the feature count); averaging many decorrelated trees cancels their individual errors. The default is 100 trees; more trees mostly cost time, not accuracy.13
20. How does gradient boosting work, and which settings matter?Medium
Each new tree fits the remaining errors (the loss gradient) and is added with a small weight, the learning rate; a lower rate needs more trees. Tune the learning rate, the number of trees, depth and early stopping. scikit-learn’s HistGradientBoosting is much faster from 10,000 rows, handles NaN natively and stops early by default above 10,000 samples; XGBoost also learns where missing values go.1114
21. How does KNN work, and how do you choose k?Medium
KNN predicts from the k most similar training points: a vote for classes, an average for numbers. scikit-learn’s default is k = 5 with Euclidean distance. Small k overfits, large k underfits; choose k by cross-validation, scale first, and expect trouble with many features (the curse of dimensionality) and slow predictions on big data.15
22. Explain SVM: margin, kernels, C and gammaMedium
An SVM finds the boundary with the widest margin between classes; the points on the margin are the support vectors. Kernels (RBF by default) allow curved boundaries; C trades margin width for training errors; gamma sets how far one point’s influence reaches. Fit time grows at least quadratically with rows, so big data needs LinearSVC.5
23. Why is Naive Bayes called naive?Medium
It applies Bayes’ theorem assuming every feature is independent of the others given the class, which is rarely true. It still works well for text, famously spam filtering and document classification, and it’s extremely fast.16
24. ROC AUC or precision–recall for imbalanced data?Medium
ROC AUC summarises ranking across all thresholds, but with rare positives it can look excellent while precision is poor, because the false-positive rate barely moves. The precision–recall curve, summarised by average precision, focuses on the positive class, and its random baseline is the share of positives: 0.30 means a lot when fraud is 2%.9
25. Your classes are imbalanced. What do you do?Medium
Choose a metric that counts the rare class, then try, in order: class_weight="balanced", which weights classes by n_samples / (n_classes × class count); tuning the decision threshold (question 34); and resampling such as SMOTE, which creates synthetic points on the line between a minority sample and a neighbour. Resample only training folds, inside an imbalanced-learn pipeline, and use SMOTE-NC when some columns are categorical.417
26. MAE, RMSE or R2?Medium
MAE is the average absolute error, in the target’s units. RMSE squares errors first, so big misses weigh more. R2 is the share of variance explained: 1.0 is perfect, always predicting the mean scores 0, and a worse model goes negative. MAPE breaks when actual values are near zero.18
27. Grid search or random search?Medium
Grid search tries every combination; random search samples a fixed number, which often finds good settings in far fewer fits when only a few hyperparameters matter. Both cross-validate on training data; the test set is used once, at the end.
from scipy.stats import loguniform
from sklearn.model_selection import RandomizedSearchCV
search = RandomizedSearchCV(model, {"clf__C": loguniform(1e-3, 1e2)}, n_iter=20,
cv=5, scoring="average_precision", random_state=42)
search.fit(X_train, y_train)
print(search.best_params_)28. What do p-values and Type I and II errors mean?Medium
A p-value is the probability of a result at least this extreme if the null hypothesis were true; it isn’t the probability that the null is true. A Type I error is a false positive, rejecting a true null, at the significance level’s rate (often 5%); a Type II error is missing a real effect. Power is 1 minus the Type II rate.
Hard: 12 questions
Importance, clustering, training, validation over time, and the cases and project questions that decide a round.
29. Built-in feature importance or permutation importance?Hard
A tree model’s built-in (impurity) importance comes from the training data, and scikit-learn warns it is strongly biased toward high-cardinality features such as IDs or exact amounts. Permutation importance shuffles one feature at a time on held-out data and measures the score drop; correlated features share credit, so both can look less important.6
from sklearn.inspection import permutation_importance
result = permutation_importance(model, X_test, y_test, n_repeats=10,
scoring="average_precision", random_state=42)
print(dict(zip(X_test.columns, result.importances_mean.round(3))))30. How does k-means work, and how do you choose k?Hard
It places k centroids, assigns each point to the nearest, moves each centroid to its points’ mean and repeats, minimising inertia, the within-cluster squared distance. Choose k from the elbow in inertia, the silhouette score and business sense. Scale first; it assumes round, similar-sized clusters. scikit-learn starts with k-means++ and, since 1.4, n_init="auto".19
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
X_seg = StandardScaler().fit_transform(df[["tenure_months", "complaints_90d"]])
for k in range(2, 7):
km = KMeans(n_clusters=k, random_state=42).fit(X_seg)
print(k, round(km.inertia_),
round(silhouette_score(X_seg, km.labels_, sample_size=2000, random_state=42), 3))31. What does PCA do, and when would you use it?Hard
PCA rotates the data onto new axes, the principal components, ordered by the variance each explains, so you can keep the first few: to visualise, compress or remove correlated features. scikit-learn centres but doesn’t scale the data, so standardise first; a fractional n_components keeps that share of variance.20
from sklearn.decomposition import PCA
from sklearn.pipeline import make_pipeline
pca_pipe = make_pipeline(StandardScaler(), PCA(n_components=0.95, svd_solver="full"))32. How does a neural network learn?Hard
A forward pass makes predictions; a loss measures the error; backpropagation uses the chain rule to get each weight’s gradient; gradient descent moves weights against it by a step set by the learning rate (too big diverges, too small crawls), usually on mini-batches. Non-linear activations such as ReLU let networks learn curves; stacked sigmoids can make gradients vanish; dropout curbs overfitting.
33. Why can’t you use a random split for time series?Hard
A random split trains on the future and tests on the past, which leaks. Validate forward in time: TimeSeriesSplit trains on the first k folds and tests on the next, so each training set contains the last; gap leaves a buffer between them. Build features only from data available before each prediction date.21
from sklearn.model_selection import TimeSeriesSplit
tscv = TimeSeriesSplit(n_splits=5, gap=7) # rows sorted by date; 7 rows skipped before each test fold34. Set the decision threshold for a UPI fraud modelHard
Start from costs, not 0.5: a missed fraud costs money and trust; a false alarm blocks a genuine customer. Agree a target, such as catching 90% of fraud, then choose the threshold with the best precision at that recall on validation data. TunedThresholdClassifierCV (scikit-learn 1.5) picks the threshold that maximises a metric you choose, by cross-validation.3
from sklearn.model_selection import TunedThresholdClassifierCV
tuned = TunedThresholdClassifierCV(model, scoring="f1").fit(X_train, y_train)
print(tuned.best_threshold_)35. When is target encoding useful, and how do you avoid leakage?Hard
For categories with many values, such as pin codes or merchant IDs, one-hot makes thousands of columns. Target encoding replaces each category with a smoothed mean of the target. Encoding rows with their own targets leaks, so scikit-learn’s TargetEncoder (since 1.3) cross-fits inside fit_transform, which therefore differs from fit(X).transform(X).22
36. Case: predict which prepaid customers will churn next monthHard
Interviewers want structure, not a model name:
- Label: no recharge within 30 days of the prediction date, agreed with the business.
- Features: only data from before that date: tenure, usage trend, complaints, plan changes.
- Validation: split by time; beat a simple baseline first.
- Metric: from the action; if the team can call 1,000 customers a week, precision in the top 1,000.
- Deployment: a weekly score list, monitoring, and a holdout group to measure the effect.
37. Great validation scores, poor production results. Why?Hard
Check, in order: leakage (a feature that won’t exist at prediction time); training–serving skew (the live system computes a feature differently); data drift (inputs change when a new plan launches); concept drift (behaviour changes after a festive season); and label changes. Monitor inputs and live metrics, and retrain on a schedule or on alerts.
38. How would you A/B test a new recommendation model?Hard
State the hypothesis and one primary metric (orders per user); randomise users, not sessions; size the test from the smallest effect worth detecting and the power you want; run whole weeks to cover weekday patterns; fix the analysis before looking. Watch guardrails such as cancellations and latency, and don’t stop early when the p-value dips.
39. What do data science rounds ask about LLMs in 2026?Hard
In the 2025–2026 interview reports we read, several IT-services and analytics firms added GenAI to data science rounds: how transformers and attention work, what embeddings are, and when to use prompting, retrieval (RAG) or fine-tuning. Expect basics unless the role is GenAI; our generative AI interview questions cover the rest.
40. Walk us through your machine learning projectHard
Asked at every kind of company. In about two minutes:
- The problem, in business terms, and why it mattered.
- The data: source, size, the label and how you cleaned it.
- The baseline, then your model and why it beat simpler ones.
- The metric and why, and how you validated without leakage.
- Error analysis: where it fails, and what you’d try next.
Expect “why not X?” for every choice.
A 7-day practice plan
About 90 minutes a day. Run every snippet on the example data, then change one thing and predict what happens before you rerun it.
| Day | Focus | Questions | Finish when |
|---|---|---|---|
| 1 | Fundamentals, splits, overfitting | 1–7 | Bias and variance, explained with one example |
| 2 | Metrics, scaling, encoding, missing values | 8–12, 24, 26 | You can compute precision and recall by hand |
| 3 | Cross-validation, leakage, pipelines, regularisation | 13–16 | Every step of the example model inside one pipeline |
| 4 | Trees, forests, boosting, KNN, SVM, Naive Bayes | 17–23 | Bagging vs boosting in two sentences |
| 5 | Imbalance, tuning, statistics, importance | 25, 27–29, 34 | A tuned threshold you can defend |
| 6 | Unsupervised, neural networks, time series, encoding | 30–33, 35 | k chosen by elbow and silhouette |
| 7 | Cases and your project, out loud | 36–40 | Two minutes on your project, then three “why not X?” |
Then practise on real data: our 15 projects on Indian public data and the Data Scientist roadmap. On our program, Module 5 covers these topics in about 19 hours: see the curriculum.
Free, official practice: the scikit-learn user guide, its common pitfalls page, and Kaggle Learn’s Intro to Machine Learning and Intermediate Machine Learning.
Questions
What machine learning questions are asked of freshers?
Mostly fundamentals: overfitting and bias–variance, precision and recall, cross-validation and leakage, and how trees, random forests, boosting, k-means and PCA work, plus a deep dive into your own project. Many rounds also test Python, SQL and statistics.
How much maths do I need for ML interviews?
School algebra, basic probability and statistics (distributions, variance, p-values) and the idea of a derivative for gradient descent. Product-company rounds go deeper into the maths behind models; most others test whether you can explain it in plain words.
Do I need deep learning for a fresher data science job?
Know the basics: how networks learn, overfitting, CNNs for images and transformers for text. Most fresher rounds focus on classical ML, statistics and your projects.
Which scikit-learn version should I learn in 2026?
Version 1.9, the current release in October 2026. Version 1.8 deprecated LogisticRegression’s penalty parameter in favour of l1_ratio, and 1.9 deprecated SVC’s probability option, so older tutorials will show warnings.
Sources
- IIT Kanpur Students’ Placement Office, SPO Insights (students’ interview write-ups, 2024–2026), read 22 Oct 2026.
- scikit-learn 1.9 documentation, Common pitfalls and recommended practices, read 22 Oct 2026.
- scikit-learn 1.9 documentation, Tuning the decision threshold for class prediction and TunedThresholdClassifierCV, read 22 Oct 2026.
- scikit-learn 1.9 documentation, LogisticRegression, read 22 Oct 2026.
- scikit-learn 1.9 documentation, SVC, read 22 Oct 2026.
- scikit-learn 1.9 documentation, Permutation feature importance, read 22 Oct 2026.
- scikit-learn 1.9 documentation, train_test_split, read 22 Oct 2026.
- scikit-learn 1.9 documentation, confusion_matrix, read 22 Oct 2026.
- scikit-learn 1.9 documentation, Metrics and scoring (precision, recall, F1, ROC AUC, average precision), read 22 Oct 2026.
- scikit-learn 1.9 documentation, OneHotEncoder, read 22 Oct 2026.
- scikit-learn 1.9 documentation, HistGradientBoostingClassifier and RandomForestClassifier, read 22 Oct 2026.
- scikit-learn 1.9 documentation, cross_val_score, read 22 Oct 2026.
- scikit-learn 1.9 documentation, DecisionTreeClassifier and RandomForestClassifier, read 22 Oct 2026.
- XGBoost documentation, Frequently Asked Questions (missing values), read 22 Oct 2026.
- scikit-learn 1.9 documentation, KNeighborsClassifier, read 22 Oct 2026.
- scikit-learn 1.9 documentation, Naive Bayes, read 22 Oct 2026.
- imbalanced-learn 0.14 documentation, Over-sampling (SMOTE) and Common pitfalls and recommended practices, read 22 Oct 2026.
- scikit-learn 1.9 documentation, r2_score, read 22 Oct 2026.
- scikit-learn 1.9 documentation, KMeans, read 22 Oct 2026.
- scikit-learn 1.9 documentation, PCA, read 22 Oct 2026.
- scikit-learn 1.9 documentation, TimeSeriesSplit, read 22 Oct 2026.
- scikit-learn 1.9 documentation, TargetEncoder, read 22 Oct 2026.





