What interviewers actually check in a Data Scientist interview
A data science interview is not a memory test on algorithm names. Interviewers check whether you understand the statistics, can prepare messy data, pick the right model and metric, and explain the result to a business user. The six areas below come up in almost every data scientist interview, from fresher to senior level.
Statistics and probability
Distributions, Central Limit Theorem, p-value, hypothesis testing, confidence intervals and A/B testing. The foundation of every model you build.
Machine learning fundamentals
Bias-variance, overfitting, regularisation, cross-validation, tree models, ensemble methods and when to use each algorithm.
Data preparation and feature engineering
Missing values, outliers, imbalanced data, encoding, scaling, feature selection and detecting data leakage.
Python and SQL
Pandas, NumPy, scikit-learn, matplotlib and seaborn — plus SQL joins, window functions and CTEs for pulling data.
Metrics and evaluation
Precision, recall, F1, ROC-AUC, RMSE, MAE — and knowing which metric matches the business problem, not just which is easiest to compute.
Communication and deployment
Explaining a model to a non-technical stakeholder, model monitoring, retraining and how a model reaches production.
Data scientist interview questions for freshers
These are the questions that come first in a fresher data science interview. Answer with a short definition, then one line of why it matters in a real project.
Q01 What is the difference between supervised and unsupervised learning? +
Supervised learning uses labelled data — each row has an input and the correct output. The model learns the mapping. Examples: predicting house price (regression), classifying email as spam (classification).
Unsupervised learning uses data without labels. The model finds structure on its own. Examples: grouping customers into segments (clustering), reducing dimensions (PCA), finding anomalous transactions.
There is also semi-supervised learning, which uses a small labelled set plus a large unlabelled set — common in NLP and image tagging.
Q02 What is the Central Limit Theorem, and why does it matter? +
The Central Limit Theorem (CLT) says that if you take many independent random samples from any population and compute the mean of each sample, the distribution of those sample means will approach a normal distribution — as long as the sample size is large enough (usually n ≥ 30).
It matters because most statistical tests — t-tests, confidence intervals, A/B testing — assume a normal distribution of the sample mean. CLT is the reason those tests work even when the underlying population is not normal.
Q03 What is a p-value? +
A p-value is the probability of observing a result at least as extreme as the one you got, assuming the null hypothesis is true.
A small p-value (typically less than 0.05) means the observed effect would be unlikely if the null hypothesis were true, so you reject the null. A large p-value means there is not enough evidence to reject it.
A p-value is not the probability that the null hypothesis is true, and it is not the size of the effect. Always report the effect size alongside it.
Q04 What is the difference between Type I and Type II errors? +
| Error | Meaning | Example |
|---|---|---|
| Type I (false positive) | Rejecting a true null hypothesis | Concluding a new drug works when it does not |
| Type II (false negative) | Failing to reject a false null hypothesis | Concluding a new drug does not work when it does |
Type I error is controlled by the significance level (alpha). Type II error is related to power (1 − beta). Reducing one usually increases the other unless you increase sample size.
Q05 What is the bias-variance trade-off? +
Bias is the error from a model that is too simple — it misses the real pattern. Variance is the error from a model that is too complex — it fits the training noise and does not generalise.
The trade-off: as you make a model more complex, bias goes down but variance goes up. Total error is the sum of bias squared, variance and irreducible error.
The goal is not the lowest bias or the lowest variance — it is the lowest total error on unseen data. Regularisation, cross-validation and ensembling help find that balance.
Q06 What is overfitting, and how do you prevent it? +
Overfitting is when a model learns the training data too well — including its noise — and performs badly on new data. The training score is high but the validation score is much lower.
Ways to prevent it:
- More data — the simplest and most reliable fix.
- Simpler model — fewer parameters, shallower trees, fewer features.
- Regularisation — L1, L2 or dropout.
- Cross-validation — to detect overfitting early.
- Early stopping — for gradient boosting and neural networks.
- Ensembling — bagging and averaging reduce variance.
Q07 What is the difference between precision and recall? +
| Metric | Formula | Answers |
|---|---|---|
| Precision | TP / (TP + FP) | Of the ones I flagged, how many were correct? |
| Recall | TP / (TP + FN) | Of all the real positives, how many did I catch? |
| F1 score | 2 × (P × R) / (P + R) | Harmonic mean — balances both when you need one number |
Choose precision when false positives are costly — for example, flagging a genuine transaction as fraud. Choose recall when false negatives are costly — for example, missing a cancer diagnosis.
Q08 What is cross-validation, and why do we use it? +
Cross-validation splits the training data into k folds. The model trains on k−1 folds and validates on the remaining fold, repeated k times. The average score across folds is a more reliable estimate of performance than a single train/validation split.
k = 5 or 10 is standard. Use StratifiedKFold for classification so each fold has the same class balance. Use TimeSeriesSplit for time-series data — a random split would leak future data into training.
Q09 How do you handle missing values? +
Options, roughly in order of preference:
- Understand why the value is missing. Is it truly random, or does the missingness carry meaning? "No value" in a "date of first purchase" column often means "never purchased".
- Drop rows or columns — only when the missing proportion is small (under 5%) and the rows are not important.
- Impute the mean or median — for numeric columns with few missing values. Median is safer with outliers.
- Impute the mode — for categorical columns.
- Forward or backward fill — for time-series data.
- Model-based imputation — KNNImputer or IterativeImputer for a principled approach.
- Add a "was_missing" flag column — so the model can learn from the missingness itself.
Always fit the imputer on the training set and apply the same transformation to the validation and test sets. Fitting on the full dataset is a data leakage bug.
Q10 What is feature engineering, and give two examples. +
Feature engineering is creating new input variables from existing data so the model can learn a pattern more easily. It is often worth more than a fancier algorithm.
Examples:
- Date features — from a timestamp, create day of week, month, quarter, is_weekend, is_holiday. Time patterns become learnable.
- Ratio features — from "amount" and "income", create "amount_to_income". A ratio often predicts default risk better than the raw values.
- Aggregate features — from a transaction table, create "average order value per customer" or "days since last purchase".
- Text features — from a description, create word count, has_url, sentiment score.
Q11 What is the difference between a parameter and a hyperparameter? +
A parameter is learned by the model during training. Example: the coefficients in linear regression, the weights in a neural network.
A hyperparameter is set by you before training. Example: the number of trees in a random forest, the depth of a decision tree, the learning rate in gradient descent.
Hyperparameters are tuned with grid search, random search or Bayesian optimisation — always using cross-validation on the training set, never on the test set.
Q12 What is the difference between classification and regression? +
| Classification | Regression |
|---|---|
| Predicts a category | Predicts a number |
| Output is discrete | Output is continuous |
| Spam / not spam, disease / no disease | House price, temperature, revenue |
| Metrics: accuracy, precision, recall, F1, AUC | Metrics: RMSE, MAE, R² |
| Models: logistic regression, decision tree, random forest classifier | Models: linear regression, ridge, lasso, gradient boosting regressor |
Logistic regression is a classification algorithm despite the name — it outputs a probability between 0 and 1.
Q13 What is a confusion matrix? +
A confusion matrix is a table showing the four outcomes of a binary classifier:
| Predicted positive | Predicted negative | |
|---|---|---|
| Actual positive | True Positive (TP) | False Negative (FN) |
| Actual negative | False Positive (FP) | True Negative (TN) |
From these four numbers you compute accuracy, precision, recall, F1 and specificity. For imbalanced data, always look at the confusion matrix — accuracy alone is misleading.
Q14 What is the difference between a population and a sample? +
A population is every member of the group you want to study. A sample is the subset you actually measure.
In practice you almost never have the full population — you have a sample. Statistical inference is the process of drawing conclusions about the population from the sample, with a stated level of uncertainty.
A sample must be representative — a sample of only one city cannot tell you about the whole country.
Q15 What is A/B testing? +
A/B testing is a controlled experiment where users are randomly split into two groups — A (control) and B (treatment). Group A sees the current version, group B sees the change. You compare a metric (click-through rate, conversion, revenue) between the two groups.
Steps:
- State the hypothesis and the primary metric.
- Calculate the sample size needed for the effect you want to detect.
- Randomly assign users to A or B — never split by time or geography only.
- Run the test long enough — usually one to two full weeks to capture weekly patterns.
- Run a t-test or a proportion test. Report the effect size and a confidence interval, not only the p-value.
Intermediate data scientist interview questions
These come up for candidates with 2–4 years of experience. They test whether you can build a model that generalises and explain why it works.
Q16 What is regularisation, and how do L1 and L2 differ? +
Regularisation adds a penalty to the loss function for large coefficients. This reduces variance and prevents overfitting.
| L1 (Lasso) | L2 (Ridge) |
|---|---|
| Penalty = sum of |coefficients| | Penalty = sum of coefficients squared |
| Can shrink coefficients to exactly zero | Shrinks coefficients but never to zero |
| Performs feature selection | Keeps all features, reduces their influence |
| Good when few features matter | Good when many features matter a little |
Elastic Net combines both. The strength
is controlled by the hyperparameter
alpha (or C in
scikit-learn, where smaller C means stronger
regularisation).
Q17 How do you handle imbalanced data? +
Options, roughly in order:
- Change the metric. Accuracy is meaningless for 1% fraud data. Use precision-recall AUC, F1 or the cost-weighted metric.
- Adjust class weights. Set
class_weight='balanced'in scikit-learn. This is the simplest effective fix. - Change the threshold. A model that predicts 0.5 by default may need a threshold of 0.2 to catch more positives.
- Oversample the minority class — SMOTE creates synthetic minority samples by interpolating between neighbours.
- Undersample the majority class — loses information but is fast.
- Collect more data — if the minority class can be expanded.
Always split into train and test before applying SMOTE. Oversampling before splitting creates duplicates across train and test — a classic leakage bug.
Q18 What is the difference between bagging and boosting? +
| Bagging | Boosting |
|---|---|
| Trains models in parallel on bootstrapped samples | Trains models sequentially, each fixing the errors of the previous |
| Reduces variance | Reduces bias |
| Less prone to overfitting | Can overfit if not regularised |
| Example: Random Forest | Examples: AdaBoost, Gradient Boosting, XGBoost, LightGBM, CatBoost |
| Each tree is deep and independent | Each tree is shallow and dependent |
In practice, gradient boosting usually wins on tabular data. Random Forest is a strong, easy baseline that needs less tuning.
Q19 How does a random forest work? +
A random forest builds many decision trees, each on a different bootstrap sample of the data, and each split considers only a random subset of features.
Key ideas:
- Bagging — each tree sees a different sample of rows.
- Feature randomness — each split considers
sqrt(n_features)features for classification,n_features/3for regression. - Aggregation — classification: majority vote. Regression: average.
Two big advantages: it needs very little preprocessing, and it gives you feature importance out of the box.
Q20 What is the difference between ROC-AUC and PR-AUC? +
ROC-AUC plots True Positive Rate against False Positive Rate across all thresholds. It measures how well the model ranks positives above negatives.
PR-AUC (Precision-Recall AUC) plots Precision against Recall. It focuses on the minority (positive) class.
For imbalanced data, PR-AUC is usually the better metric. ROC-AUC can look optimistic because the large number of true negatives inflates the FPR denominator. Say this in an interview and you show real understanding.
Q21 What is feature scaling, and when is it needed? +
Feature scaling puts numeric features on a similar range so no single feature dominates because of its units.
| Method | Result | Use when |
|---|---|---|
| StandardScaler | Mean 0, std 1 | Most algorithms, especially linear models |
| MinMaxScaler | Range 0 to 1 | Neural networks, image data |
| RobustScaler | Median and IQR based | Data with outliers |
Needed for: linear regression with regularisation, logistic regression, k-NN, SVM, PCA, k-means, neural networks.
Not needed for: decision trees, random forest, gradient boosting — they split on thresholds, so scale does not matter.
Always fit the scaler on the training set only and apply the same scaler to the validation and test sets.
Q22 What is data leakage, and how do you detect it? +
Data leakage is when information from the target or from the future leaks into the training features. The model looks excellent in validation and fails in production.
Common causes:
- Fitting the scaler or imputer on the full dataset before splitting.
- Target leakage — a feature that is only available after the outcome. Example: "loan default date" as a feature for predicting default.
- Time-based leakage — using future rows to predict past rows, or a random split on time-series data.
- Duplicate rows across train and test — often introduced by oversampling before the split.
Detection: if a model has suspiciously high performance (AUC above 0.99 on a hard problem), suspect leakage. Check the feature importance and the data pipeline carefully.
Q23 What is PCA, and when do you use it? +
PCA (Principal Component Analysis) is a dimensionality reduction technique. It finds new axes (principal components) that capture the maximum variance in the data, ordered from most to least important.
When to use it:
- High-dimensional data — hundreds or thousands of features.
- Visualisation — reduce to 2 or 3 components and plot.
- Removing multicollinearity — components are uncorrelated.
- Speeding up a slow model — fewer features mean faster training.
Downside: components are linear combinations of the original features, so you lose interpretability. Always scale features before PCA — otherwise large-unit features dominate.
Q24 How does k-means clustering work? +
k-means is an iterative algorithm:
- Choose k — the number of clusters.
- Initialise k centroids randomly (or with k-means++).
- Assign each point to the nearest centroid.
- Recompute each centroid as the mean of its assigned points.
- Repeat steps 3 and 4 until assignments stop changing or the max iterations is reached.
Choosing k: use the elbow method (plot inertia vs k) or the silhouette score.
Limitations: you must specify k in advance, it assumes spherical clusters of similar size, and it is sensitive to outliers and scale. Always scale features before running k-means.
Q25 What is the difference between grid search and random search? +
| Grid Search | Random Search |
|---|---|
| Tests every combination in a grid | Tests random combinations from a distribution |
| Exhaustive — always finds the best point in the grid | May miss the exact best point |
| Slow when there are many hyperparameters | Fast, scales to many hyperparameters |
| Good for 2–3 parameters | Better for many parameters |
Research shows random search finds a good configuration faster than grid search when only a few hyperparameters matter. Use Bayesian optimisation (Optuna, Hyperopt) when training is expensive — it learns from previous trials.
Q26 How do you detect and handle outliers? +
Detection methods:
- IQR method — values below Q1 − 1.5×IQR or above Q3 + 1.5×IQR are outliers.
- Z-score — values more than 3 standard deviations from the mean.
- Isolation Forest — a tree-based anomaly detector for high-dimensional data.
- Visual — box plot, scatter plot, histogram.
Handling options:
- Keep them if they are real and important — for example, a large enterprise customer.
- Cap them (winsorise) at a percentile such as 1% and 99%.
- Remove them only if they are data errors and the proportion is small.
- Use a robust model — tree-based models handle outliers better than linear models.
Never remove outliers blindly. Investigate first, and document the decision.
Q27 What is the difference between a parametric and non-parametric test? +
A parametric test assumes the data follows a known distribution — usually normal. Examples: t-test, ANOVA, Pearson correlation.
A non-parametric test makes no distribution assumption. It usually works on ranks. Examples: Mann-Whitney U, Wilcoxon signed-rank, Kruskal-Wallis, Spearman correlation.
Use non-parametric tests when the sample is small, the data is heavily skewed, or the variable is ordinal. They are often slightly less powerful when the normality assumption actually holds.
Q28 How do you decide between a simple model and a complex one? +
Ask these questions in order:
- What is the metric? If the business cares about accuracy, the metric decides. Compare models on a held-out validation set, not on the training set.
- How much data do you have? With little data, a simple model wins. With lots of data, complex models usually perform better.
- Does the stakeholder need to understand the model? If yes, logistic regression or a shallow tree beats a deep neural network, even at slightly lower accuracy.
- What is the inference cost? A model that takes 2 seconds to score will not serve real-time traffic.
- How often will the model be retrained? Complex models take longer to train and to maintain.
Start simple. A logistic regression baseline that you can explain beats a black box you cannot defend.
Q29 What are the common SQL queries a data scientist writes? +
Data scientists use SQL to pull training data and features. The most common patterns:
-- Filter and aggregate
SELECT customer_id, SUM(amount) AS total_spend
FROM orders
WHERE order_date >= '2025-01-01'
GROUP BY customer_id
HAVING SUM(amount) > 10000;
-- Window function for ranking
SELECT customer_id, order_date, amount,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY order_date) AS rn
FROM orders;
-- CTE for a feature table
WITH recent_orders AS (
SELECT customer_id, MAX(order_date) AS last_order
FROM orders
GROUP BY customer_id
)
SELECT c.customer_id,
DATEDIFF(CURRENT_DATE, r.last_order) AS days_since_last_order
FROM customers c
LEFT JOIN recent_orders r ON c.customer_id = r.customer_id;
Focus on SELECT with WHERE, GROUP BY, JOIN, window functions and CTEs. INSERT, UPDATE and DELETE are used only in data preparation.
Q30 What is the difference between a DataFrame and a Series in pandas? +
A Series is a one-dimensional labelled array — essentially a single column. It has an index and a value for each index entry.
A DataFrame is a two-dimensional table — a collection of Series that share the same index. It has rows and columns with labels for both.
import pandas as pd
s = pd.Series([10, 20, 30], name="sales")
df = pd.DataFrame({"region": ["North", "South"],
"sales": [100, 200]})
print(type(df["sales"])) # Series
print(df.shape) # (2, 2)
Data scientist interview questions for experienced professionals
These come up for candidates with 5+ years of experience or for senior data scientist roles. They test judgement, architecture and how you deploy and monitor a model.
Q31 How would you design a machine learning pipeline for production? +
Step 1 — Data ingestion. Scheduled jobs pull data from source systems into a warehouse or feature store. Version the raw data.
Step 2 — Feature engineering. Reusable features live in a feature store so training and serving use the same transformation code.
Step 3 — Training. Runs on a schedule or on trigger. Trains on a defined window, logs metrics and artifacts to MLflow or a similar tool.
Step 4 — Evaluation. Compare the new model to the current production model on the same holdout set. Add a business rule or human review for high-impact decisions.
Step 5 — Deployment. Package as an API (FastAPI, Flask) or a batch job. Containerise with Docker. Deploy with a blue-green or canary strategy.
Step 6 — Monitoring. Track input drift (PSI, KL divergence), prediction distribution, latency and business metrics. Alert on drift or on metric degradation.
Step 7 — Retraining. Define a trigger — a drop in performance, or a fixed cadence. Automate the retraining path so it does not depend on someone remembering.
Q32 How do you monitor a model in production? +
Three levels of monitoring:
- Operational. Is the API up? What is the latency? What is the error rate? What is the throughput? This is standard application monitoring.
- Data and feature drift. Are the input distributions still similar to training? Use Population Stability Index (PSI) or KL divergence. Alert when a key feature moves by more than a threshold.
- Model performance. When the labels arrive, compute precision, recall, RMSE, AUC and compare to baseline. Where labels are delayed, use proxy metrics that correlate with the target.
Also track prediction distribution — a shift in the fraction of positives is often the first sign of a change before labels arrive. Set alerts so the team is paged only when the change is meaningful.
Q33 How do you explain a complex model to a business stakeholder? +
Do not talk about the algorithm. Talk about the outcome and the risk.
Structure:
- What the model does in one sentence — "It predicts which customers are likely to leave in the next 30 days."
- How well it works using a business metric — "It catches 70% of churners with a 15% false-positive rate."
- What drives the prediction using SHAP or feature importance — "The top three factors are days since last login, contract type and number of support tickets."
- What action to take — "We will offer a retention discount to the top 10% by predicted risk."
- What can go wrong — "If the usage data feed is delayed, predictions may be stale."
Use SHAP summary plots and one or two individual predictions. Avoid talking about gradient boosting, learning rates or log-loss unless asked.
Q34 How do you decide which model to deploy — accuracy or business cost? +
Business cost, always. Higher accuracy is only useful if it translates to better business outcomes.
Approach:
- Estimate the cost of a false positive and a false negative. For a fraud model, a false positive blocks a good customer; a false negative lets fraud through.
- Build a cost-weighted metric — expected cost = FP × cost_FP + FN × cost_FN.
- Tune the threshold to minimise the expected cost, not to maximise accuracy.
- Compare candidate models on this cost metric, not on accuracy.
- Confirm with the business that the cost estimates are realistic.
A model with 80% accuracy that minimises business cost beats a 90% accurate model that does not.
Q35 What is the difference between a feature store and a data warehouse? +
| Data warehouse | Feature store |
|---|---|
| Stores cleaned, modelled data for reporting | Stores features specifically for ML models |
| Optimised for SQL analytics | Optimised for both training (batch) and serving (low latency) |
| Consumers: analysts, BI tools | Consumers: ML training and serving pipelines |
| Example: Snowflake, BigQuery, Redshift | Example: Feast, Tecton, Databricks Feature Store |
The problem a feature store solves is training-serving skew — when the feature computed during training differs from the feature computed during serving. One codebase, one definition of each feature.
Q36 How do you handle a stakeholder asking for "explainable AI"? +
Ask what they actually need. "Explainable" can mean three different things:
- Global explainability. Which features drive the model overall? Use feature importance or SHAP summary plots.
- Local explainability. Why did the model make this specific prediction? Use SHAP force plots or LIME.
- Regulatory explainability. Can we justify a decision to a customer or a regulator? This usually needs a simpler, interpretable model.
For regulatory or legal use cases, a logistic regression or a shallow decision tree with clear rules is often the correct answer, even at slightly lower accuracy. Explainability is a requirement, not an optional extra.
Q37 How do you build a recommendation system? +
Three main approaches:
- Content-based. Recommend items similar to what the user liked before. Use item features (genre, category, tags) and similarity metrics.
- Collaborative filtering. Use the pattern of user-item interactions. User-based: find similar users. Item-based: find similar items. Matrix factorisation (ALS, SVD) learns latent factors for users and items.
- Hybrid. Combine both. Most production systems use a two-stage design: candidate generation (fast recall of thousands of items) then ranking (a heavier model scores the top hundreds).
Evaluation: offline (precision@k, recall@k, NDCG) then online (A/B test on click-through rate, conversion, watch time).
Cold start is the hard problem — a new user or a new item has no history. Solve with popularity fallback, content features or contextual signals.
Q38 What are transformers and LLMs at a concept level? +
A transformer is a neural network architecture built on self-attention. Instead of processing a sequence one step at a time like an RNN, it looks at all positions in the sequence in parallel and learns which positions matter for each other.
Key components: multi-head self-attention, positional encoding, feed-forward layers, layer normalisation, and residual connections. The original transformer had an encoder (for understanding) and a decoder (for generation).
An LLM (Large Language Model) is a very large transformer trained on a huge text corpus using self-supervised learning — predict the next token. Examples: GPT, Claude, Llama, Gemini. They power chat assistants, summarisation, code generation and retrieval-augmented generation (RAG) systems.
At a data science interview level, know the architecture, the training objective (next-token prediction), the difference between encoder-only (BERT for classification) and decoder-only (GPT for generation), and when an LLM is the right tool versus a classical model.
Q39 How do you detect and correct data drift? +
Data drift is a change in the input distribution. Concept drift is a change in the relationship between inputs and the target.
Detection:
- Statistical tests — Kolmogorov-Smirnov for numeric features, chi-square for categorical features.
- Population Stability Index (PSI) — a single number per feature. PSI above 0.2 usually triggers investigation.
- Monitor model performance when labels arrive. A drop in AUC or a shift in error rate is a signal.
- Prediction distribution — a shift in the fraction of positives is often the earliest indicator.
Correction:
- Retrain on recent data — the simplest and often the correct answer.
- Reweight training data to emphasise recent rows.
- Recalibrate the model outputs if the ranking is still good but the probability scale is off.
- Rebuild the feature pipeline if the drift is caused by a change in the upstream system.
Q40 How do you deploy a model as an API? +
Typical steps:
- Save the model. Use joblib or pickle for scikit-learn; SavedModel or ONNX for deep learning.
- Wrap in a web framework. FastAPI or Flask exposes a
/predictendpoint that accepts JSON, runs the model and returns the prediction. - Containerise. A Docker image with the model, the code and the dependencies pinned.
- Deploy. To a container service — Kubernetes, AWS ECS, Azure Container Apps, GCP Cloud Run.
- Add observability. Log every request with the input, the prediction and the latency. Alert on errors and on drift.
- Version and roll back. Deploy as a new version with a canary or blue-green strategy so you can revert quickly.
from fastapi import FastAPI
from pydantic import BaseModel
import joblib
app = FastAPI()
model = joblib.load("model.pkl")
class Features(BaseModel):
tenure: int
monthly_charges: float
@app.post("/predict")
def predict(f: Features):
X = [[f.tenure, f.monthly_charges]]
prob = model.predict_proba(X)[0][1]
return {"churn_probability": float(prob)}
Q41 How do you approach an NLP classification problem? +
Step 1 — Understand the text. Language, average length, number of classes, class balance. Sample a few examples manually.
Step 2 — Baseline. TF-IDF with logistic regression. Fast, interpretable and often surprisingly strong. Do not skip this step.
Step 3 — Preprocessing. Lowercase, remove URLs, expand contractions. Skip heavy stemming or stop-word removal for transformer models — they handle raw text well.
Step 4 — Transformer model. Fine-tune a pretrained model such as DistilBERT or RoBERTa. Even with a few thousand labelled examples, this beats TF-IDF.
Step 5 — Evaluate per class. Look at the confusion matrix, not only the overall F1. Look at misclassified examples — the errors usually reveal a data quality problem.
Step 6 — Handle imbalance with class weights or threshold tuning, not with accuracy.
Q42 How do you measure the business impact of a model? +
Connect the model metric to a business metric. A model is only useful if it changes a decision.
Approach:
- State the decision the model supports — who will act on the prediction, and what will they do?
- Map the model metric to the business metric. AUC 0.85 is not useful; "₹2 crore of retained revenue from 1,000 targeted customers" is.
- Quantify with an A/B test or a holdout. Compare the treated group to a control group and measure the incremental revenue or cost.
- Report the confidence interval, not just the point estimate.
- Track the impact after deployment — does the benefit persist, or decay as the model ages?
Scenario-based data scientist interview questions
These are the questions an interviewer asks when they want to see how you think under a realistic problem. Answer with a step-by-step approach.
S01 Your model has 98% accuracy but the business says it is useless. What is happening? +
Step 1 — Suspect class imbalance. If 98% of the data is one class, a model that always predicts the majority class gets 98% accuracy and predicts nothing useful.
Step 2 — Look at the confusion matrix and per-class metrics. Precision and recall for the minority class are almost certainly close to zero.
Step 3 — Switch the metric to PR-AUC, F1 or the cost-weighted business metric.
Step 4 — Fix the class imbalance with class weights, resampling or threshold tuning.
Step 5 — Re-evaluate against the business metric: how many of the actual positives are being caught, and at what false-positive cost?
S02 Your model performs great in validation but fails in production. How do you debug it? +
Step 1 — Compare the distribution of each feature in production to the training set. A shift in a key feature is the most common cause.
Step 2 — Check for data leakage in the validation setup. A model that looked too good in validation is suspicious.
Step 3 — Check training-serving skew — the feature computed during training must be identical to the one served in production.
Step 4 — Check the time window. Did you train on older data and evaluate on recent data with a different pattern?
Step 5 — Check the scoring pipeline itself — a missing feature, a wrong default value, a different column order.
Step 6 — Rebuild the validation set to match production conditions — time-based split, same feature pipeline, same pre-processing.
S03 The business wants to predict customer churn. How do you frame the problem? +
Step 1 — Define churn precisely. Is it no purchase in 90 days, cancellation of a subscription, or a drop in usage below a threshold? The definition drives the labels.
Step 2 — Define the prediction window. Are we predicting churn in the next 30 days, 90 days or a quarter?
Step 3 — Define the action. Will marketing send a discount to high-risk customers? Will support proactively call them? The action determines the metric and the threshold.
Step 4 — Choose the metric. If the action is a costly discount, precision matters. If the action is a cheap email, recall matters more.
Step 5 — Build a baseline — logistic regression on usage and tenure. Then try gradient boosting. Compare on the same time-based holdout.
Step 6 — Ship with an A/B test. Measure the retained revenue, not just the model metric.
S04 An A/B test shows a positive lift but the p-value is 0.12. What do you tell the business? +
Step 1 — Explain that with p = 0.12 there is a 12% chance of seeing this result if the change had no effect. That is above the standard 5% threshold, so the result is not statistically significant.
Step 2 — Look at the confidence interval on the lift. If it spans zero, the effect could be zero or even negative.
Step 3 — Check the sample size and duration. Was the test powered to detect the effect size the business cares about?
Step 4 — Check for novelty effects or segment-level effects that the aggregate is hiding.
Step 5 — Recommend one of: extend the test, ship if the business accepts the risk, or do not ship. Never call an insignificant result "positive".
S05 You have six months of data and 300 features. How do you decide what to keep? +
Step 1 — Remove features that leak the target or that would not be available at prediction time.
Step 2 — Remove constant and near-constant features — they carry no signal.
Step 3 — Remove highly correlated features. Keep one of each pair above 0.95 correlation.
Step 4 — Check missing-value rate. Features with more than 60-70% missing are usually not worth the imputation effort.
Step 5 — Use a filter method — correlation with the target, mutual information — to shortlist the top 60-80 features.
Step 6 — Use an embedded method — L1 regularisation or tree feature importance — to reduce further.
Step 7 — Compare model performance with the shortlisted set vs the full set on a validation split. If the metric is the same, keep the smaller set.
S06 Your team has no labelled data for a new classification problem. How do you start? +
Step 1 — Check for a proxy label. For churn, "no purchase in 90 days". For fraud, "chargeback raised". A proxy is often good enough to start.
Step 2 — Use weak supervision — rules, heuristics or pattern matching to label a subset with high precision.
Step 3 — Hand-label a small, high-quality set — 500 to 2,000 examples. This is often faster than building a labelling pipeline.
Step 4 — Use a pretrained model as a starting point — a transformer for text, a pretrained CNN for images. Fine-tune on the small labelled set.
Step 5 — Use active learning — train on the small labelled set, then have a human label the examples the model is most unsure about.
Step 6 — Ship an MVP that is better than the current rule-based system, and improve the labels over time.
S07 A stakeholder asks "why did the model reject this specific customer?" How do you answer? +
Step 1 — Use a local explanation method — SHAP force plot or LIME — on the specific prediction.
Step 2 — Translate the top three to five contributing features into business language. "High debt-to-income ratio, short credit history and recent missed payment pushed this application below the threshold."
Step 3 — Show the magnitude and direction of each feature's contribution, not just the feature names.
Step 4 — If the model is a black box and the decision is high-stakes, consider training a simpler surrogate model — a shallow decision tree — to approximate the black box for explanation purposes.
Step 5 — Have a manual review path for borderline or disputed decisions. Explainability is not a substitute for oversight.
S08 You need to deliver a data science project in 4 weeks. How do you scope it? +
Week 1 — Data and framing. Confirm the business question, get access to the data, profile it, and set up a simple baseline model. Share a short written problem statement with the stakeholder.
Week 2 — Baseline model. Build a logistic regression or decision tree. Measure it on a time-based holdout. Present the baseline result — "here is what a simple model can do".
Week 3 — Improve. Feature engineering, gradient boosting, hyperparameter tuning. Cap the improvement work at three days — diminishing returns kick in quickly.
Week 4 — Wrap. Explain the model with SHAP, write a short memo, prepare a deck, and define what "deployed" means — an API, a batch job or a notebook the analyst runs manually.
Set expectations early. A working model in week 2 that the business can react to beats a perfect model delivered on the last day.
Data science coding round — Python, pandas and scikit-learn
These are the six tasks that come up most often in a data science coding round. Each snippet is complete and runnable as shown, with the expected output underneath. Type each one in a notebook before your interview.
C01 Load a CSV, inspect it, and handle missing values +
import pandas as pd
df = pd.read_csv("customers.csv")
print(df.shape)
print(df.isnull().sum())
# Fill numeric columns with the median
num_cols = df.select_dtypes(include="number").columns
df[num_cols] = df[num_cols].fillna(df[num_cols].median())
# Fill categorical columns with the mode
cat_cols = df.select_dtypes(include="object").columns
for c in cat_cols:
df[c] = df[c].fillna(df[c].mode()[0])
print(df.isnull().sum().sum())
(1000, 12) tenure 0 monthly 15 city 3 dtype: int64 0
Always inspect the missing count before deciding the imputation strategy. Fill numeric columns with median (safer with outliers) and categorical columns with mode.
C02 Feature engineering — extract date features from a timestamp +
import pandas as pd
df = pd.DataFrame({
"order_id": [1, 2, 3],
"order_ts": ["2026-01-05 10:30", "2026-03-15 18:00", "2026-05-28 08:15"]
})
df["order_ts"] = pd.to_datetime(df["order_ts"])
df["year"] = df["order_ts"].dt.year
df["month"] = df["order_ts"].dt.month
df["day_of_week"] = df["order_ts"].dt.dayofweek
df["is_weekend"] = df["order_ts"].dt.dayofweek >= 5
df["hour"] = df["order_ts"].dt.hour
print(df)
order_id order_ts year month day_of_week is_weekend hour 0 1 2026-01-05 10:30:00 2026 1 0 False 10 1 2 2026-03-15 18:00:00 2026 3 6 True 18 2 3 2026-05-28 08:15:00 2026 5 3 False 8
Convert to datetime first, then use the
.dt accessor. The same pattern
works for any timestamp column and is the
fastest way to make time patterns learnable.
C03 Build a scikit-learn pipeline with preprocessing and a classifier +
from sklearn.model_selection import train_test_split
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.impute import SimpleImputer
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
num_cols = ["tenure", "monthly_charges"]
cat_cols = ["contract", "payment_method"]
num_pipe = Pipeline([
("imp", SimpleImputer(strategy="median")),
("sc", StandardScaler())
])
cat_pipe = Pipeline([
("imp", SimpleImputer(strategy="most_frequent")),
("oh", OneHotEncoder(handle_unknown="ignore"))
])
preprocess = ColumnTransformer([
("num", num_pipe, num_cols),
("cat", cat_pipe, cat_cols)
])
model = Pipeline([
("prep", preprocess),
("clf", RandomForestClassifier(n_estimators=300, random_state=42))
])
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.2, stratify=y, random_state=42)
model.fit(X_train, y_train)
print(classification_report(y_test, model.predict(X_test)))
precision recall f1-score support
0 0.85 0.90 0.87 120
1 0.72 0.62 0.67 50
accuracy 0.82 170
The pipeline ensures the same preprocessing is applied at training and scoring. It also prevents leakage — the imputer and scaler are fit only on the training folds during cross-validation.
C04 Cross-validate and tune hyperparameters with GridSearchCV +
from sklearn.model_selection import GridSearchCV, StratifiedKFold
from sklearn.ensemble import GradientBoostingClassifier
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)
param_grid = {
"clf__n_estimators": [100, 300],
"clf__max_depth": [3, 5, 7],
"clf__learning_rate": [0.05, 0.1]
}
grid = GridSearchCV(
model, param_grid, cv=cv, scoring="roc_auc",
n_jobs=-1, verbose=0)
grid.fit(X_train, y_train)
print("Best params:", grid.best_params_)
print("Best CV AUC:", round(grid.best_score_, 3))
print("Test AUC:", round(grid.score(X_test, y_test), 3))
Best params: {'clf__learning_rate': 0.1, 'clf__max_depth': 5, 'clf__n_estimators': 300}
Best CV AUC: 0.864
Test AUC: 0.859
If the CV AUC is much higher than the test AUC, the tuning has started to overfit the validation folds. Use nested cross-validation or a separate holdout for model selection.
C05 Handle imbalanced data with class weights and evaluate with PR-AUC +
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import average_precision_score, roc_auc_score
import numpy as np
# 2% positive class
model = LogisticRegression(
class_weight="balanced", max_iter=1000, random_state=42)
model.fit(X_train, y_train)
probs = model.predict_proba(X_test)[:, 1]
print("PR-AUC:", round(average_precision_score(y_test, probs), 3))
print("ROC-AUC:", round(roc_auc_score(y_test, probs), 3))
# Tune the threshold for F1
from sklearn.metrics import precision_recall_curve, f1_score
prec, rec, thr = precision_recall_curve(y_test, probs)
f1 = 2 * prec * rec / (prec + rec + 1e-9)
best_thr = thr[np.argmax(f1[:-1])]
print("Best threshold:", round(best_thr, 3))
PR-AUC: 0.412 ROC-AUC: 0.876 Best threshold: 0.34
With 2% positives, the ROC-AUC of 0.88 looks great but the PR-AUC of 0.41 shows the real challenge. Always report both, and tune the threshold using the PR curve, not the default 0.5.
C06 Explain a model with SHAP values +
import shap
import pandas as pd
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=300, random_state=42)
model.fit(X_train, y_train)
# TreeExplainer is fast for tree models
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_test)
# Global feature importance
shap.summary_plot(shap_values, X_test, plot_type="bar")
# Mean absolute SHAP value per feature
importance = pd.Series(
abs(shap_values).mean(axis=0),
index=X_test.columns
).sort_values(ascending=False)
print(importance.head(5))
tenure 0.187 monthly_charges 0.142 contract 0.098 payment_method 0.061 num_support 0.052
SHAP gives both a global view (which features
drive the model overall) and a local view
(why this specific prediction was made). Use
the summary_plot in a business
deck and the force_plot for an
individual decision.
Machine learning case study — problem framing to business answer
The case study round is where interviewers see how you think end to end. Each case study below follows the same structure: problem framing → data → features → model → metric → business answer.
Case study 1 — Predicting credit card default for a bank
CS1 A bank wants to predict which credit card customers will default next month. Walk through the full approach. +
Problem framing. Binary classification: will this customer default in the next 30 days? Decision: reduce credit limit or flag for a retention/support call. The cost of a false negative (letting a defaulter through) is much higher than a false positive (a good customer gets a smaller limit).
Data. Historical transaction, repayment and account data for the last two years. Typical columns: age, credit limit, bill amounts, previous payments, education, marital status, default flag from the prior month.
Features.
- Utilisation ratio = bill amount ÷ credit limit.
- Payment ratio = payment ÷ bill amount (last month, average of last three months).
- Delinquency count — number of months with a payment delay in the last 6 and 12 months.
- Months on book — tenure with the bank.
- Bill trend — slope of the bill amount over the last six months.
Model. Start with logistic regression for a strong baseline and for the coefficients that a compliance team can review. Move to gradient boosting (XGBoost or LightGBM) for the production model. Use stratified 5-fold cross-validation, and split by time — train on months 1–18, validate on 19–21, test on 22–24.
Metric. Because of class imbalance (defaults are typically 2–5% of accounts), use PR-AUC as the main metric, and recall at a fixed precision as a business metric. Also report the confusion matrix at the chosen threshold.
Explainability. SHAP values per customer so the bank can explain a decision. The top drivers are usually utilisation, delinquency count and payment ratio — all of which make intuitive sense and match the domain.
Business answer. Deploy the model as a monthly batch job. Score all active accounts and hand the top risk bucket to the risk team for review. Run an A/B test for three months — a control group reviewed by the current rule and a treatment group reviewed by the model — and compare the loss rate. If the model reduces default loss by even 10-15%, it pays back the cost of building it.
Case study 2 — Reducing customer churn for a subscription business
CS2 A subscription business wants to reduce churn by 20%. Design the full data science approach. +
Problem framing. Two problems, not one. First: predict which customers will churn in the next 30 days. Second: estimate the effect of a retention action on a churner. The 20% reduction target is a business target, not a model metric.
Data. Usage logs, subscription details, billing history, support tickets and app events, joined at the customer-month level.
Features.
- Recency: days since last login, days since last payment.
- Frequency: logins in the last 7, 30, 90 days; sessions per week.
- Monetary: monthly recurring revenue, average order value.
- Engagement trend: slope of logins over the last 3 months — a falling trend predicts churn better than any absolute value.
- Support signals: number of tickets, average resolution time, sentiment of the last ticket.
- Contract: plan type, tenure, discount applied, auto-renew flag.
Model. Gradient boosting (LightGBM or XGBoost) for the churn classifier. For the uplift model (who will respond to the retention offer), use a two-model approach — one model on the treatment group, one on the control group — and compute the difference. This is the correct approach when you have historical A/B test data.
Metric. PR-AUC for the churn classifier. For the retention decision, use uplift at the top decile — how much incremental retention does the offer create among the highest-uplift customers? Not the overall churn rate, which hides the effect on customers who would have stayed anyway.
Business answer. Do not send the retention offer to every predicted churner — many will stay without an offer. Send it only to customers with a high predicted churn risk AND a positive predicted uplift. Run a proper A/B test with a control group to measure the incremental retention. A model that identifies 1,000 truly persuadable customers is worth more than one that identifies 10,000 churners.
Data science cheat table — 15 one-line reminders
Skim this on the morning of your interview. One line per topic, exactly what you need to trigger a fuller answer.
| Topic | One-line reminder |
|---|---|
| Supervised vs unsupervised | Supervised uses labels; unsupervised finds structure without labels. |
| Central Limit Theorem | Sample means approach a normal distribution as sample size grows, usually n ≥ 30. |
| p-value | Probability of seeing this result if the null is true. Not the probability the null is true. |
| Type I vs Type II | Type I = false positive; Type II = false negative. |
| Bias vs variance | Bias = too simple; variance = too complex. Minimise total error, not either one. |
| Overfitting | High training score, low validation score. Fix with more data, regularisation, cross-validation. |
| Precision vs recall | Precision = TP/(TP+FP). Recall = TP/(TP+FN). Choose by the cost of each error. |
| ROC-AUC vs PR-AUC | PR-AUC is better on imbalanced data; ROC-AUC can look optimistic. |
| Cross-validation | K-fold, StratifiedKFold for classification, TimeSeriesSplit for time series. |
| Missing values | Investigate first. Median for numeric, mode for categorical, KNN for a principled approach. |
| Imbalanced data | Class weights, threshold tuning, SMOTE — always split before resampling. |
| Data leakage | Fit scaler and imputer on training only. Watch for target and time leakage. |
| L1 vs L2 | L1 (Lasso) can zero coefficients — feature selection. L2 (Ridge) shrinks but keeps all. |
| Bagging vs boosting | Bagging: parallel, reduces variance. Boosting: sequential, reduces bias. |
| Scaling | Needed for linear models, SVM, k-NN, PCA, neural networks. Not for tree models. |
| PCA | Dimensionality reduction. Scale first. Components are linear combinations of features. |
| Grid vs random search | Random search scales to many hyperparameters; grid is exhaustive but slow. |
| A/B test | State hypothesis, calculate sample size, randomise, run for full weeks, report the effect size. |
| Model deployment | Save model, wrap in FastAPI or Flask, containerise, log inputs and outputs. |
| Model monitoring | Track operational metrics, feature drift (PSI), prediction distribution and business metrics. |
How to prepare for a Data Scientist interview in 7 days
If your interview is next week, follow this plan. Each day has one focus and one practice task. Do not just read — open a notebook and run the code.
| Day | Focus | Practice task |
|---|---|---|
| Day 1 | Statistics and probability | Answer Q2–Q4, Q14, Q15, Q27 out loud. Compute a confidence interval and run a t-test on a small sample in Python. |
| Day 2 | ML fundamentals | Answer Q5, Q6, Q11, Q12, Q16, Q28. Train a logistic regression, a random forest and a gradient boosting model on the same dataset. Compare AUC. |
| Day 3 | Data preparation and feature engineering | Answer Q9, Q10, Q17, Q21, Q22, Q26. Build a scikit-learn pipeline with an imputer, a scaler, an encoder and a classifier. |
| Day 4 | Metrics and model evaluation | Answer Q7, Q13, Q20. Plot a confusion matrix, an ROC curve and a PR curve for an imbalanced dataset. Report all four metrics. |
| Day 5 | Python coding round | Redo the 6 tasks in section 06 from memory. Focus on pipelines, cross-validation and SHAP. |
| Day 6 | SQL and case studies | Answer Q29 and one scenario question per level. Solve one of the two case studies in section 07 out loud, without notes. |
| Day 7 | Mock interview and revision | Answer one scenario question per level out loud. Redo both case studies in 20 minutes each. Revise the cheat table. |
Common mistakes candidates make in data science interviews
Jumping to the model before the problem
Interviewers want to hear "what decision will this model change?" before the algorithm. A model with no decision attached has no value.
Using accuracy on imbalanced data
A 1% fraud model that always predicts "no fraud" has 99% accuracy. Always report precision, recall, F1 and PR-AUC for imbalanced problems.
Ignoring data leakage
Fitting a scaler or imputer before the train-test split is a classic mistake. Always split first, then preprocess inside a pipeline.
Saying "I would use XGBoost" without a reason
Interviewers want the reasoning, not the tool name. Explain why gradient boosting fits tabular data with mixed feature types, and when a simpler model is the better choice.
Not mentioning explainability
For any model that affects a person — credit, hiring, insurance — explainability is a requirement. Mention SHAP and the business need to justify decisions.
Reading code instead of writing it
You will not remember how to write a ColumnTransformer or a GridSearchCV from reading it three times. Write each snippet once, then again without looking.
Practise these topics with Uncodemy
Statistics, machine learning, deep learning, NLP and Python are taught inside Uncodemy's Data Science program. The Data Analytics with Gen AI program covers the analyst side of the same stack — SQL, Excel, Power BI and Python — in a shorter track.
| Program | What it covers | Duration / fee |
|---|---|---|
| Data Science | SQL, Excel, Power BI, Python for Data Science, statistics, machine learning, deep learning, NLP, 7 projects. This is the direct track for the topics on this page. | ₹21,500 + GST · 8–9 months |
| Data Analytics with Gen AI | SQL & database management (18 h), Excel (12 h), Power BI (18 h), Python (20 h), plus Gen AI usage for analytics. | ₹17,500 + GST · 6–7 months |
| Artificial Intelligence | 200+ hours, 130+ live sessions; Python, statistics, ML, deep learning (CNN, RNN/LSTM), autoencoders, transfer learning, GANs; TensorFlow, PyTorch, Scikit-learn, Hugging Face, OpenCV. Does not cover LLM apps, RAG, LangChain or AI agents. | Ask a counsellor for current batch details. |
Placement assistance (as published by Uncodemy): resume building, LinkedIn optimisation, portfolio review, interview preparation, mock interviews and opportunity sharing through a network of 850+ companies. Uncodemy does not guarantee employment, as hiring decisions rest with employers. See placement support.
Also useful: AI career guidance for picking between data science, analytics and AI engineering roles, and the 2-class free trial to see how a live batch runs before you commit.