Data Scientist Interview Questions and Answers
34 data scientist interview questions with answers: statistics, A/B testing, machine learning, model evaluation, feature engineering, SQL and Python, product case questions.
Key takeaways
- Data science interviews combine statistics, machine learning, coding and product sense; weak spots in any one can sink the loop.
- A/B testing questions (sample size, p-values, pitfalls) appear in almost every product data science interview.
- For ML questions, interviewers care about trade-offs and evaluation, not reciting algorithms.
- Expect SQL and Python/pandas live coding, plus a case question where you define metrics.
Contents
Data scientist interviews test four skills at once: statistics, machine learning, coding and product sense. Below are 34 common questions grouped by topic and level, with concise answers and code.
What data scientist interviews cover
Editorial estimate for a product data scientist role; ML-heavy roles shift weight toward modeling.
- Statistics and A/B testing25%
- Machine learning20%
- SQL and Python coding25%
- Product and case questions20%
- Behavioral10%
Classification metrics at a glance
| Situation | Metric | Why |
|---|---|---|
| Balanced classes | Accuracy, ROC AUC | Simple and threshold-independent |
| Rare positives (fraud, disease) | Precision, recall, PR AUC | Accuracy hides poor detection |
| Ranking matters | ROC AUC, NDCG | Order of predictions is the goal |
| Probabilities are used directly | Log loss, calibration | Quality of the probability itself |
| Business cost is known | Expected cost or profit | Optimizes the real objective |
Related: machine learning engineer, data analyst and SQL interview questions.
Statistics and probability
1Explain p-values in plain language.
JuniorA p-value is the probability of seeing results at least as extreme as yours if the null hypothesis were true. A small p-value means the data would be surprising under the null. It is not the probability that the null hypothesis is true, and it says nothing about the size of the effect.
2Type I vs Type II error?
JuniorA Type I error is a false positive: concluding there is an effect when there isn’t (probability α, often 5%). A Type II error is a false negative: missing a real effect (probability β). Power is 1 − β, the chance of detecting a real effect of a given size.
3What is the central limit theorem, and why does it matter?
JuniorFor independent samples, the distribution of the sample mean approaches a normal distribution as the sample size grows, whatever the original distribution (with finite variance). It justifies confidence intervals and many tests on means, such as comparing conversion rates in an A/B test.
4What is a confidence interval?
MidA range produced by a procedure that, over many repeated samples, contains the true parameter a given share of the time (for example 95%). For a single interval, it is not a 95% probability that the true value lies inside it; that is the Bayesian credible interval.
5Correlation vs causation: how can you establish causation?
MidCorrelation can come from confounders, reverse causation or chance. Randomized experiments are the most reliable way to establish causation. When they’re impossible, use quasi-experimental methods: difference-in-differences, regression discontinuity, instrumental variables or matching, each with its own assumptions.
6A test for a rare disease is 99% accurate. If you test positive, how likely are you to have the disease?
MidIt depends on prevalence (Bayes’ theorem). With 1 in 1,000 people affected, among 100,000 people, about 100 are sick (99 test positive) and 99,900 are healthy (about 999 false positives). So the chance of being sick after a positive test is about 99 / (99 + 999) ≈ 9%.
A/B testing
7How do you design an A/B test?
MidDefine the hypothesis and one primary metric, choose guardrail metrics, decide the unit of randomization (user, session), calculate the sample size from the baseline rate, the minimum detectable effect, α and power, run for full weekly cycles, and decide the analysis plan before looking at results.
8What determines the sample size of an experiment?
MidThe baseline rate and its variance, the minimum detectable effect, the significance level α and the desired power. Halving the detectable effect roughly quadruples the required sample size.
9Why is peeking at A/B test results a problem?
MidChecking significance repeatedly and stopping when p < 0.05 inflates the false positive rate well above 5%. Fix the duration in advance or use sequential testing methods designed for continuous monitoring.
10Your test shows a significant lift, but you’re suspicious. What do you check?
SeniorSample ratio mismatch (unequal group sizes than planned), bugs in assignment or logging, novelty effects, outliers driving the result, multiple metrics tested without correction, a too-short test, and whether the effect is consistent across segments and over time.
11When can’t you use a standard A/B test?
SeniorWhen users influence each other (network effects in marketplaces or social products), when randomizing by user is impossible, or with too little traffic. Options: cluster or geo randomization, switchback tests over time, or causal inference on observational data.
Get Data Scientist answer points in real time during your interview
Sottena listens to the interviewer, detects each question and shows short answer points in about a second. 150 free credits, no card required.
Machine learning
12Explain the bias-variance trade-off.
JuniorBias is error from overly simple assumptions (underfitting); variance is sensitivity to the particular training data (overfitting). More complex models reduce bias but increase variance. Regularization, more data and cross-validation help find the balance.
13How do you detect and prevent overfitting?
JuniorDetect it when training performance is much better than validation performance. Prevent it with cross-validation, regularization (L1, L2), simpler models, early stopping, more data, and removing leaky features.
14L1 vs L2 regularization?
MidBoth penalize large weights. L1 (lasso) can push weights to exactly zero, performing feature selection. L2 (ridge) shrinks weights smoothly and handles correlated features better. Elastic net combines both.
15How does a random forest differ from gradient boosting?
MidA random forest trains many deep trees independently on bootstrapped samples and averages them, reducing variance. Gradient boosting trains shallow trees sequentially, each correcting the previous errors, reducing bias. Boosting (XGBoost, LightGBM) often wins on tabular data but needs more careful tuning.
16How does logistic regression work?
MidIt models the log-odds of the positive class as a linear function of features and applies the sigmoid to get a probability. It is trained by maximizing likelihood (minimizing log loss). It’s fast, interpretable and a strong baseline for classification.
17What is data leakage? Give examples.
MidInformation in training that won’t be available at prediction time, which makes offline results look unrealistically good. Examples: features computed after the outcome, scaling fitted on the full dataset before splitting, and random splits for time series instead of time-based splits.
18How would you explain a model’s predictions to stakeholders?
SeniorUse global explanations (feature importance, partial dependence) to show what drives the model overall, and local ones (SHAP values) for individual predictions. Translate them into business terms, show examples, and be clear about limitations and correlation versus causation.
Model evaluation
19Precision vs recall?
JuniorPrecision: of the items predicted positive, how many are positive. Recall: of the actual positives, how many were found. Fraud detection may prioritize recall; a spam filter that shouldn’t hide real emails prioritizes precision. F1 combines both.
20Why is accuracy misleading for imbalanced data?
MidWith 1% positives, a model that always predicts negative is 99% accurate and useless. Use precision, recall, the precision-recall curve, or a business-weighted cost, and consider resampling or class weights.
21What does ROC AUC measure?
MidThe probability that the model ranks a random positive above a random negative. It is threshold-independent. For heavily imbalanced problems, PR AUC is often more informative because ROC AUC can look good even with many false positives.
22How do you choose a classification threshold?
MidBased on the business cost of false positives and false negatives, not the default 0.5. Plot precision and recall (or expected profit) against the threshold and pick the point that matches the business goal, then monitor it in production.
23How do you evaluate a model after deployment?
SeniorMonitor input data drift, prediction distribution, and actual outcomes when labels arrive. Compare against a baseline, and ideally run an online A/B test, since offline metrics don’t always translate into business impact.
Feature engineering and data
24How do you handle missing values?
JuniorFirst understand why they’re missing. Options: drop rows or columns, impute with median or mode, use model-based imputation, or add a “missing” indicator, which often carries signal. Tree-based models like gradient boosting can handle missing values natively.
25How do you encode categorical variables?
MidOne-hot encoding for low-cardinality categories; target encoding (with cross-validation to avoid leakage) or embeddings for high-cardinality ones; ordinal encoding when the order is meaningful. Tree models can also use native categorical support in some libraries.
26When do you need feature scaling?
MidFor models sensitive to feature magnitude: linear models with regularization, k-NN, SVMs, neural networks and PCA. Tree-based models don’t need it. Fit the scaler on training data only.
Coding: SQL and Python
27Compute daily active users and a 7-day rolling average in SQL.
MidWITH dau AS (
SELECT event_date, COUNT(DISTINCT user_id) AS users
FROM events GROUP BY event_date
)
SELECT event_date, users,
AVG(users) OVER (ORDER BY event_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS dau_7d
FROM dau;
28In pandas, compute conversion rate by channel.
Midconv = (df.groupby("channel")
.agg(users=("user_id", "nunique"), buyers=("purchased", "sum"))
.assign(rate=lambda t: t.buyers / t.users)
.sort_values("rate", ascending=False))
29How do you split data for a time-dependent problem?
JuniorBy time: train on the past and validate on a later period, never randomly, otherwise future information leaks into training. For tuning, use rolling or expanding-window cross-validation.
30Write a function to bootstrap a confidence interval for the mean.
Midimport numpy as np
def bootstrap_ci(x, n=10_000, alpha=0.05, seed=0):
rng = np.random.default_rng(seed)
means = rng.choice(x, size=(n, len(x)), replace=True).mean(axis=1)
return np.quantile(means, [alpha / 2, 1 - alpha / 2])
Product and case questions
31Daily active users dropped 10% yesterday. How do you investigate?
MidFirst check data issues (logging, pipeline delays, definition changes). Then check external factors (holidays, outages, seasonality), segment the drop by platform, app version, country and acquisition channel, and look at the funnel to see where users fall off. Form hypotheses and test them one by one.
32How would you measure the success of a new feature?
MidTie it to the feature’s goal: choose a primary metric (adoption, retention, conversion), guardrail metrics (performance, cancellations, support tickets), and a counter-metric that could get worse. Measure with an experiment if possible, and define success thresholds before launch.
33How would you build a churn prediction model, end to end?
SeniorDefine churn precisely and the prediction horizon, build features from usage, billing and support data as of the prediction date, train a baseline (logistic regression) and a gradient boosting model, evaluate with time-based validation and business-relevant metrics, and plan the action: who gets an intervention, and how you’ll measure its effect with an experiment.
34Tell me about a project where your analysis changed a decision.
SeniorUse the STAR method: the business question, your approach and why you chose it, what you found, and the concrete decision and impact. Interviewers listen for problem framing, communication with stakeholders, and how you handled uncertainty in the data.
How to prepare
- Refresh statistics fundamentalsHypothesis testing, confidence intervals, Bayes’ theorem, power and sample size.
- Practice A/B test cases end to endDesign, sample size, pitfalls and how you’d explain the result.
- Explain ML trade-offs, not definitionsWhy this model, how you evaluated it, what could go wrong in production.
- Do timed SQL and pandas exercisesWindow functions, cohorts, funnels and group-bys.
- Prepare two project storiesOne with a business impact, one where something went wrong.
Get answer points in real time during your interview
Sottena listens to the interviewer, detects each question and shows short answer points in about a second. 150 free credits, no card required.