Data Science Interview Questions 2026: Freshers to 10 Years, Statistics, ML, SQL and Case Rounds
Data science interview guide: round pattern, statistics and probability, machine learning algorithms and metrics, SQL, Python for data, A/B testing, case studies and project explanation, with expected answers and charts.
How to use this guide
This guide covers data science interviews from statistics to production machine learning. Read each answer, then explain it in your own words. Interviewers often ask you to justify a choice, so the reasoning matters more than the formula.
The answers follow standard definitions from statistics and machine learning. Libraries change, so check the current documentation for exact function names. The guide does not attribute any experience to a named person or company.
What the interview pattern usually looks like
| Round | What is tested | Typical length |
|---|---|---|
| Screening | Statistics, SQL, one short ML question | 30 minutes |
| Technical | Statistics, ML concepts, Python or R | 45 to 60 minutes |
| SQL or coding test | Joins, aggregates, window functions, a small Python task | 60 minutes |
| Case study | "How would you reduce churn?" or "How would you measure this feature?" | 45 minutes |
| Project discussion | Your end-to-end project | 30 to 45 minutes |
| Manager | Business sense, communication, ownership | 30 minutes |
Service companies test SQL and basic ML in depth. Product companies ask more about experiments, metric design and case studies.
Level 1: Statistics and probability
Q1. What is the difference between mean, median and mode, and when do you use the median?
The mean is the average. The median is the middle value when sorted. The mode is the most frequent value. Use the median for skewed data such as income, because a few very large values pull the mean up.
Q2. What is standard deviation, and how is it different from variance?
Variance is the average squared distance from the mean. Standard deviation is its square root, which returns to the original units. A higher standard deviation means the values are more spread out.
Q3. What is a p-value?
The probability of seeing a result at least as extreme as the one observed, assuming the null hypothesis is true. A small p-value means the data is unlikely under the null. It is not the probability that the null hypothesis is true, and it does not measure effect size.
Q4. What are Type I and Type II errors?
A Type I error is a false positive: rejecting a true null hypothesis. A Type II error is a false negative: failing to reject a false null. The significance level alpha controls the Type I error rate. Power, which is one minus the Type II error rate, rises with sample size.
Q5. What is the Central Limit Theorem, and why does it matter?
For a large enough sample, the distribution of the sample mean is approximately normal, whatever the population distribution. This is why confidence intervals and many tests work on averages of real data.
Q6. What is a confidence interval?
A range built from the data that, under repeated sampling, would contain the true value at the stated rate, such as 95 percent. Say it carefully. The interval either contains the value or it does not, and the 95 percent refers to the procedure.
Q7. What is the difference between correlation and causation?
Correlation measures how two variables move together. Causation means one changes the other. A randomised experiment supports causation. Observational data needs more care, such as a controlled design or a causal method.
Q8. What is conditional probability and Bayes' theorem?
Conditional probability is the chance of A given B: P(A|B) = P(A and B) divided by P(B). Bayes' theorem reverses it: P(A|B) = P(B|A) times P(A) divided by P(B). A common example is a medical test: a positive result from a rare disease can still be mostly false positives.
Disease rate 1 percent, test sensitivity 99 percent, false positive rate 5 percent.
P(disease | positive) = 0.99 x 0.01 / (0.99 x 0.01 + 0.05 x 0.99) ≈ 0.167
A positive result means about a 17 percent chance of disease, not 99.
Q9. What is the difference between a normal, a skewed and a heavy-tailed distribution?
A normal distribution is symmetric with a bell shape. Skewed distributions have a long tail on one side. Heavy-tailed distributions have more extreme values than a normal, which makes the mean unstable and often calls for robust methods.
Q10. What is a t-test, and when do you use it instead of a z-test?
Both compare means. A t-test is used when the population standard deviation is unknown and the sample is small, and it uses the t distribution. With large samples the two give nearly the same answer.
Q11. What is the difference between a one-tailed and a two-tailed test?
A two-tailed test checks for a difference in either direction. A one-tailed test checks for a difference in one direction only. Choose the direction before you see the data, or you are tempted to pick the tail that gives the result you want.
Level 2: Machine learning foundations
Q12. What is the difference between supervised, unsupervised and reinforcement learning?
Supervised learning uses labelled examples to predict a label or value. Unsupervised learning finds structure without labels, such as clusters. Reinforcement learning learns actions through rewards from an environment.
Q13. What is overfitting, and how do you detect and reduce it?
The model learns noise in the training data and performs worse on new data. Detect it by a gap between training and validation scores. Reduce it with more data, regularisation, simpler models, early stopping, and cross-validation.
Q14. Explain bias and variance.
Bias is error from wrong assumptions in the model, which causes underfitting. Variance is error from sensitivity to the training data, which causes overfitting. Increasing model complexity lowers bias and raises variance. The goal is the balance with the lowest total error on new data.
Q15. What is cross-validation, and why not just use one train and test split?
K-fold cross-validation splits the data into K parts, trains on K minus one, tests on the remaining one, and repeats. Averaging the scores gives a more stable estimate than a single split, which depends on which rows landed in the test set.
Q16. What is data leakage? Give an example.
Information from outside the training window, or from the target itself, enters the features. For example, using "refund issued" as a feature to predict whether a customer will churn, when the refund happens after churn. The model looks great in testing and fails in production.
Q17. How do you handle missing values?
First understand why values are missing. Options: drop rows if few, impute with the median or mode, use a model-based imputation, or add an indicator column that marks the missing value. Always fit the imputer on the training data only.
Q18. What is feature scaling, and which models need it?
Scaling puts features on a comparable range. Distance-based models such as k-nearest neighbours and SVM, and gradient-based models such as linear and logistic regression with regularisation, need it. Tree-based models do not.
Q19. What is regularisation?
A penalty on large coefficients. L1 (lasso) can shrink coefficients to exactly zero, which selects features. L2 (ridge) shrinks them smoothly. Elastic net combines both.
Q20. What is the difference between one-hot and label encoding?
Label encoding maps categories to integers, which implies an order that may not exist. One-hot encoding creates one column per category, which avoids false order but adds columns. For high-cardinality categories, consider target encoding carefully, with cross-validation to avoid leakage.
Level 3: Algorithms you must explain
Know how each algorithm works, its main assumptions, and when you would use it.
Q21. Explain linear regression and its assumptions.
It fits a weighted sum of features to predict a number. Assumptions include linearity, independent errors, constant error variance, and roughly normal errors for inference. Check residual plots to see if they hold.
Q22. What is logistic regression, and why is it used for classification?
It models the probability of a class by passing a linear score through the sigmoid function. Its output is a probability, and its coefficients have a direct interpretation through odds.
Q23. How does a decision tree split the data?
It picks the feature and threshold that best separate the classes at each node, measured by Gini impurity or entropy for classification, and by variance reduction for regression. It grows until a stopping rule applies, then prunes to avoid overfitting.
Q24. Why do random forests work better than a single tree?
A random forest trains many trees on bootstrap samples and random feature subsets, then averages or votes. Averaging reduces variance. The trees are decorrelated by the random feature choice.
Q25. What is gradient boosting?
Trees are added one after another, and each new tree fits the errors of the ensemble so far. Learning rate and the number of trees control the trade-off between bias and variance. XGBoost, LightGBM and CatBoost are common implementations.
Q26. Explain k-means clustering and its limits.
K-means assigns each point to the nearest of K centroids, then moves each centroid to the mean of its points, and repeats until stable. You must choose K in advance. It assumes roughly round clusters of similar size and is sensitive to scaling and starting points.
Q27. What is principal component analysis?
PCA finds directions of maximum variance and projects the data onto the top few. It reduces dimensions while keeping most of the variance. Scale the features first, or the largest-scale feature dominates.
Q28. How does k-nearest neighbours work, and what is its main cost?
It predicts from the K closest training points. Training is fast, but prediction is slow for large data and needs a meaningful distance metric. Scaling matters.
Level 4: Evaluation metrics
Q29. Why is accuracy a poor metric for imbalanced data?
If 99 percent of transactions are legitimate, a model that always predicts legitimate has 99 percent accuracy and catches no fraud. Use precision, recall, F1, PR-AUC, or a cost-based metric.
Predicted yes Predicted no
Actually yes True positive False negative
Actually no False positive True negative
Precision = TP / (TP + FP) ... of the flagged, how many were right
Recall = TP / (TP + FN) ... of the real positives, how many were caught
Q30. What is the difference between precision and recall, and how do you choose?
Choose by the cost of each error. For a spam filter, high precision avoids losing real mail. For a cancer screen, high recall avoids missing cases. Adjust the decision threshold to trade one against the other, and show the precision-recall curve to the business.
Q31. What is ROC-AUC?
The area under the curve of true positive rate against false positive rate, across all thresholds. It measures how well the model ranks positives above negatives. For heavily imbalanced data, PR-AUC is often more informative.
Q32. What is a regression metric you would report?
Mean absolute error for an error in the original units that is robust to outliers. Root mean squared error when large errors should be penalised more. R-squared for the share of variance explained, with the caution that it always rises when you add features.
Q33. How do you choose a threshold for a classifier?
Pick the threshold that meets the business constraint, such as recall at least 90 percent, or the one that maximises expected value with the cost of each error. Choose it on validation data, not on the test set.
Level 5: SQL and pandas
Most data science rounds test SQL. Write the query, state the grain of each table, and check for duplicates.
Q34. What is the difference between INNER, LEFT, RIGHT and FULL joins?
INNER keeps matching rows only. LEFT keeps all rows from the left table, with nulls where there is no match. RIGHT is the mirror. FULL keeps all rows from both sides. A common bug is a join that multiplies rows because one key is not unique.
Q35. Find the second highest salary in a table.
SELECT MAX(salary) AS second_highest
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
Mention the alternative with DENSE_RANK() in a window function, which handles ties the way the question intends.
Q36. Find duplicate emails in a users table.
SELECT email, COUNT(*) AS n
FROM users
GROUP BY email
HAVING COUNT(*) > 1;
Q37. Calculate the running total of sales per month.
SELECT month,
SUM(sales) OVER (ORDER BY month) AS running_total
FROM monthly_sales;
Q38. What is the difference between WHERE and HAVING?
WHERE filters rows before grouping. HAVING filters groups after aggregation.
Q39. How do you handle missing values and duplicates in pandas?
df = df.drop_duplicates(subset=["user_id", "event_date"])
df["amount"] = df["amount"].fillna(df["amount"].median())
df = df.dropna(subset=["user_id"])
Explain the choice: drop duplicates by the key that defines a unique record, impute with the median for skewed data, and drop rows without an identifier.
Level 6: Experimentation and A/B testing
Q40. How do you design an A/B test?
- State the hypothesis and the primary metric.
- Pick a minimum detectable effect that matters to the business.
- Calculate the sample size from the baseline rate, the effect, the significance level and the power.
- Randomise users, not page views, so the same user sees one variant.
- Run for a full business cycle, such as one or two weeks, to cover weekday patterns.
- Check for sample ratio mismatch before reading the result.
- Decide on the planned metric, and report guardrail metrics too.
Q41. What is a sample ratio mismatch, and why does it matter?
When the observed split between groups differs from the planned split, such as 52 to 48 when you planned 50 to 50. It signals a bug in assignment or logging, so the results cannot be trusted until it is fixed.
Q42. What is the peeking problem?
Checking the p-value repeatedly during a test and stopping at the first significant result inflates false positives. Use a fixed sample size, or a sequential method designed for repeated looks.
Q43. A test shows a 2 percent lift with p = 0.04. Do you ship it?
Not on that alone. Check the confidence interval, the practical size of the lift, the guardrail metrics, the sample size and whether the test ran long enough. A small significant lift that costs more to maintain may not be worth shipping.
Level 7: Case studies and production ML
Q44. How would you reduce customer churn?
Structure the answer:
- Define churn: the time window, the event, and the segment.
- Measure: churn rate by segment, the reasons customers give, and a cohort view.
- Find drivers: compare churned and retained users on usage, support tickets, price, and product features.
- Build a model to predict churn risk, with the cost of each error stated.
- Act: a targeted offer or onboarding fix for high-risk users, tested with an experiment.
- Monitor the business result, not only the model score.
Q45. How would you measure the success of a new feature?
Pick one primary metric tied to the goal, such as retention or conversion. Add guardrails such as revenue and crash rate. Use an experiment when possible. If not, use a quasi-experiment such as difference-in-differences, and state the assumptions.
Q46. How do you deploy a machine learning model?
Package the model with its preprocessing, expose it through an API or a batch job, version the model and the data, monitor input drift and performance, and have a rollback. Keep training and serving code consistent so the features are computed the same way.
Q47. What is data drift, and how do you detect it?
A change in the input distribution over time. Detect it by comparing recent feature distributions with the training data, using a statistic such as the population stability index or a statistical test, and by watching model performance when labels arrive.
Q48. What is model explainability, and which tools do you use?
Explaining why a model made a prediction. For linear models, coefficients. For tree models, feature importance and SHAP values. Explain to the business in plain terms, and check that explanations do not hide a leakage problem.
Coding and SQL problems
C1. Write a function that returns the top K frequent elements.
Use a counter, then take the K most common. In an interview, state the complexity: counting is O(n), selecting the top K is O(n log K) with a heap.
from collections import Counter
import heapq
def top_k(nums, k):
counts = Counter(nums)
return [item for item, _ in heapq.nlargest(k, counts.items(), key=lambda p: p[1])]
C2. Compute a 7-day moving average of daily active users in SQL.
SELECT day,
AVG(dau) OVER (ORDER BY day ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS dau_7d
FROM daily_active_users;
C3. Find users who made a purchase in each of the last three months.
Group by user and month, filter to the three months, and count distinct months per user, then keep users whose count is three.
How to answer 'explain a project'
Use a clear structure:
- The business question and the decision it supports.
- The data: sources, grain, size, and the cleaning steps that mattered.
- The method and why you chose it over one alternative.
- The evaluation: the metric, the validation scheme, and the baseline.
- The result in business terms, with the uncertainty.
- What you would do next, including what could be wrong.
Be ready for questions on leakage, the choice of metric and how the model would be used.
Common mistakes
- Starting with a complex model. Begin with a baseline, such as the mean or logistic regression.
- Using accuracy on imbalanced data. Choose a metric that matches the cost of errors.
- Leaking test information into training. Fit preprocessing on the training data only.
- Joining tables without checking the key. Check for duplicates before and after joins.
- Reading a p-value as the probability the idea is true. Explain it precisely.
- Saying "I would use deep learning" without a reason. Justify each method.
A four-week preparation plan
| Week | Focus | Output |
|---|---|---|
| 1 | Statistics: distributions, tests, p-values, confidence intervals | Solve twenty short problems and explain each |
| 2 | ML: regression, trees, boosting, metrics, cross-validation | Train two models on one dataset with a written comparison |
| 3 | SQL: joins, window functions, grouping; pandas cleaning | Solve thirty SQL questions in increasing difficulty |
| 4 | Case studies and A/B tests; project story | Write one case answer and one experiment design |
Frequently asked questions
Is a Kaggle profile useful? It can show practical skill, but the interview cares more about your reasoning on a real problem. Explain one project in depth.
Which language should I use? Python is the most common. Know pandas, NumPy, scikit-learn and a plotting library, and be comfortable with SQL.
What if I lack business experience? Use public datasets and frame each project as a business question with a stated decision. That is the case-round skill.
Frequently Asked Questions
Not always. Many roles hire strong candidates with a bachelor's degree and a solid project portfolio. Statistics, SQL and clear communication matter more than the degree title.
The ability to turn a business question into a measurable problem, choose a suitable method, and explain the result plainly. Interviewers test this in case rounds.
For general data science roles, classical machine learning and good evaluation matter more. Deep learning is needed for computer vision and language roles.
Expect joins, grouping, window functions and a question about a duplicate or a missing record. Most rounds include a SQL test.
Pick one project and be able to explain the data, the cleaning steps, the model choice, the metric, the result and what you would improve.
Keshav founded StudentUpdate.in and edits every recruitment notice, syllabus page and practice set the site publishes. Each notice is read from the issuing body's PDF or portal before it goes live; dates, fees, vacancy tables and eligibility rules are copied from that document, not from other websites.