HireHireInterview Quizzes › Data Scientist

Data Scientist Interview Questions

Think you're ready? These are the questions that actually decide Data Scientist interviews. Warm up on Easy — then face the Hard round, where 95% of candidates crumble. 30 questions across 3 levels, instant score, completely free.

30Questions
3Difficulty levels
95%Fail the hard round
FreeInstant score
Easy
Warm-up · 10 Qs
Medium
Practical · 10 Qs
Hard
Brutal · 10 Qs
⚡ Take the Data Scientist quiz — get your score →

The Data Scientist interview questions

Below are the real questions, grouped by difficulty. Expand any one to reveal the correct answer and why — or take the timed quiz for a score you can share. Can you clear the Hard round?

Easy round 10 questions

In a classification problem with severe class imbalance (1% positive class), why is plain accuracy a misleading metric?
  • A. It cannot be computed when classes are imbalanced
  • B. A model predicting the majority class for everything can score ~99% while catching zero positives ✓
  • C. Accuracy always overweights the minority class
  • D. Accuracy requires probabilities rather than labels
Correct answer: B. With 1% positives, always predicting the majority class yields ~99% accuracy while completely missing the class of interest, so accuracy hides poor minority-class performance.
You train a model that achieves 99% accuracy on training data but 70% on the validation set. What is this a classic symptom of?
  • A. Underfitting (high bias)
  • B. Overfitting (high variance) ✓
  • C. Data leakage into the test set
  • D. An unrepresentative loss function
Correct answer: B. A large gap where training performance far exceeds validation performance indicates the model has memorized training noise, the defining sign of overfitting/high variance.
What does L1 (Lasso) regularization tend to do that L2 (Ridge) regularization does not?
  • A. Shrink all coefficients equally toward zero without eliminating any
  • B. Drive some coefficients exactly to zero, performing feature selection ✓
  • C. Guarantee a lower training error than L2
  • D. Only apply to the intercept term
Correct answer: B. The L1 penalty's geometry pushes some weights to exactly zero, effectively selecting features, whereas L2 shrinks weights smoothly but rarely to exactly zero.
In a SQL query, what is the key difference between WHERE and HAVING?
  • A. WHERE filters rows before aggregation; HAVING filters groups after aggregation ✓
  • B. HAVING filters rows before grouping; WHERE filters after
  • C. They are interchangeable in all queries
  • D. WHERE works only with JOINs and HAVING only with subqueries
Correct answer: A. WHERE filters individual rows before GROUP BY runs, while HAVING filters the aggregated groups afterward, so aggregate conditions must go in HAVING.
A p-value of 0.03 from a hypothesis test at significance level 0.05 means:
  • A. There is a 3% probability the null hypothesis is true
  • B. Under the null hypothesis, there is a 3% chance of observing data at least as extreme as this ✓
  • C. The alternative hypothesis is 97% likely to be true
  • D. The effect size is 0.03
Correct answer: B. A p-value is the probability of obtaining a result at least as extreme as observed assuming the null hypothesis is true, not the probability that the null is true.
Why should feature scaling (e.g., standardization) typically be fit on the training set and then applied to the test set, rather than fit on the full dataset?
  • A. It makes training run faster
  • B. Fitting the scaler on all data leaks test-set information into training, inflating performance estimates ✓
  • C. Scaling is only valid for tree-based models
  • D. It reduces the number of features
Correct answer: B. Computing scaling parameters from the full dataset lets test-set statistics influence training, a form of data leakage that biases evaluation optimistically.
Which algorithm is generally most sensitive to unscaled features with different magnitudes?
  • A. Decision trees
  • B. Random forests
  • C. K-Nearest Neighbors (KNN) ✓
  • D. Naive Bayes with categorical features
Correct answer: C. KNN relies on distance computations, so a feature with a large numeric range dominates the distance metric unless features are scaled, unlike tree-based methods which are scale-invariant.
In the bias-variance tradeoff, increasing a model's complexity typically has what effect?
  • A. Increases bias and decreases variance
  • B. Decreases bias and increases variance ✓
  • C. Decreases both bias and variance
  • D. Has no effect on either
Correct answer: B. More complex models fit training data more closely, reducing bias but making predictions more sensitive to the specific training sample, thus increasing variance.
For a highly right-skewed feature such as customer income, which imputation choice for missing values is generally more robust than the mean?
  • A. The maximum value
  • B. The median ✓
  • C. Zero
  • D. A randomly sampled value from a uniform distribution
Correct answer: B. The median is resistant to extreme outliers that inflate the mean in a skewed distribution, making it a more representative central value for imputation.
What does the ROC-AUC of a binary classifier represent?
  • A. The model's accuracy at the default 0.5 threshold
  • B. The probability that the model ranks a random positive higher than a random negative ✓
  • C. The precision averaged across all thresholds
  • D. The fraction of variance in the target explained by the model
Correct answer: B. ROC-AUC equals the probability that a randomly chosen positive instance receives a higher score than a randomly chosen negative one, a threshold-independent ranking measure.

Medium round 10 questions

You train a classifier and get 97% accuracy, but the business is unhappy because the model rarely catches the fraud cases it was built for. Fraud is 3% of all transactions. What is the most likely explanation?
  • A. The model is overfitting the training data
  • B. The dataset is imbalanced, so high accuracy reflects mostly predicting the majority class ✓
  • C. The learning rate was set too high
  • D. You need a larger neural network
Correct answer: B. With 3% fraud, a model predicting 'not fraud' every time scores 97% accuracy, so accuracy is misleading on imbalanced data and metrics like recall or precision-recall AUC are needed.
You fit a StandardScaler on your entire dataset and then split into train and test sets to evaluate a model. What is the problem with this workflow?
  • A. StandardScaler should only be used on tree-based models
  • B. It causes data leakage because test-set statistics inform the scaling applied to training data ✓
  • C. Scaling must always be done after model training
  • D. There is no problem; scaling before splitting is the recommended approach
Correct answer: B. Fitting the scaler on all data lets test-set information (mean/variance) leak into training, inflating performance; the scaler must be fit on the train set only and applied to the test set.
In pandas, you want to compute the average purchase amount per customer from a transactions DataFrame. Which approach is correct?
  • A. df.groupby('customer_id')['amount'].mean() ✓
  • B. df.sort_values('customer_id')['amount'].mean()
  • C. df['amount'].mean().groupby('customer_id')
  • D. df.pivot('customer_id')['amount']
Correct answer: A. groupby on customer_id followed by selecting the amount column and calling mean() produces the per-customer average, which is the standard pandas aggregation pattern.
Your Random Forest achieves near-perfect accuracy on training data but performs poorly on the validation set. Which action is most likely to help?
  • A. Increase the maximum tree depth further
  • B. Remove the validation set and train on all data
  • C. Limit tree depth or increase min_samples_leaf to reduce overfitting ✓
  • D. Switch the evaluation metric to training accuracy
Correct answer: C. The large train/validation gap indicates overfitting, and constraining tree complexity (shallower depth, larger leaf size) regularizes the forest and improves generalization.
You are running an A/B test comparing conversion rates between a control and a variant. After one day the variant looks better with p=0.04, so a colleague wants to ship it immediately. What is the best response?
  • A. Ship it; p<0.05 means the result is definitely real
  • B. Wait until the pre-determined sample size or duration is reached to avoid peeking-induced false positives ✓
  • C. Re-run the test 10 times and average the p-values
  • D. Switch to a one-tailed test to get a smaller p-value
Correct answer: B. Stopping a test early the moment significance appears (peeking) dramatically inflates the false-positive rate, so you should reach the pre-planned sample size before deciding.
You need to encode a categorical feature 'city' with about 500 unique values for a gradient-boosting model. Which approach is generally most practical?
  • A. One-hot encode all 500 values, creating 500 new columns
  • B. Drop the feature because it has too many categories
  • C. Use target/mean encoding or group rare categories, being careful to avoid leakage ✓
  • D. Convert the city names to their string length
Correct answer: C. For high-cardinality categoricals, target encoding or grouping rare levels is more practical than exploding into 500 sparse one-hot columns, provided encoding is computed within cross-validation folds to prevent leakage.
A stakeholder asks whether an outlier customer with a spend of 5,000,000 (versus a typical 200) should be summarized using the mean or the median for a 'typical customer spend' report. What do you advise?
  • A. The mean, because it uses all data points
  • B. The median, because it is robust to the extreme outlier ✓
  • C. Neither; report only the maximum value
  • D. The mean, but only after multiplying it by the outlier
Correct answer: B. The median is resistant to extreme values, so it better represents a 'typical' customer when a large outlier would drag the mean far above most observations.
You run a SQL query joining orders to customers and notice the result has more rows than the orders table. What is the most likely cause?
  • A. You used a LEFT JOIN instead of an INNER JOIN
  • B. The customers table has duplicate rows for the join key, causing row multiplication ✓
  • C. SQL always returns extra rows after a join
  • D. The ORDER BY clause duplicated the rows
Correct answer: B. When the join key is not unique on the joined side, each order matches multiple customer rows, multiplying the output row count, which is a common fan-out bug.
You are choosing between L1 (Lasso) and L2 (Ridge) regularization for a linear model with many features, and you also want automatic feature selection. Which is the better fit and why?
  • A. L2, because it drives many coefficients exactly to zero
  • B. L1, because it can shrink some coefficients exactly to zero, effectively selecting features ✓
  • C. Neither affects coefficients; both only change the intercept
  • D. L2, because it always yields sparser models than L1
Correct answer: B. L1's penalty can set coefficients exactly to zero, producing sparse models and built-in feature selection, whereas L2 shrinks coefficients toward but not exactly to zero.
During cross-validation on time-series data (predicting next month's sales), a teammate uses standard k-fold with random shuffling. Why is this problematic?
  • A. k-fold is only valid for classification, not regression
  • B. Random shuffling lets the model train on future data to predict the past, leaking temporal information ✓
  • C. Time-series data cannot be cross-validated at all
  • D. Shuffling reduces the number of folds automatically
Correct answer: B. Random k-fold ignores time order, so future observations end up in the training folds used to predict earlier points, leaking information; a forward-chaining/time-series split is required.

Hard round 10 questions

A fraud model on a dataset with 0.5% positives reports 99.4% accuracy, ROC-AUC 0.91, but the fraud team says it misses most fraud in production at the default 0.5 threshold. Which single diagnostic best explains the gap and points to the fix?
  • A. ROC-AUC is invalid on imbalanced data, so retrain with balanced class weights before trusting any metric
  • B. The PR curve / PR-AUC shows precision-recall tradeoff at operating thresholds; 0.5 sits where recall collapses, so tune the threshold on the PR curve to the business cost ratio ✓
  • C. Accuracy is high, so the model is fine and the issue is label noise in the production fraud reports
  • D. ROC-AUC of 0.91 proves the model ranks well, so the only fix is to oversample the minority class with SMOTE until classes are balanced
Correct answer: B. ROC-AUC can look strong under imbalance because true negatives dominate; the PR curve exposes the collapse in recall at 0.5 and the correct fix is choosing a cost-driven threshold rather than blindly rebalancing.
You run this query to compute month-over-month revenue growth: SELECT month, revenue, (revenue - LAG(revenue) OVER (ORDER BY month)) / LAG(revenue) OVER (ORDER BY month) AS growth FROM monthly_rev; The table has multiple months per region (region column present) but you forgot to partition. What happens?
  • A. It errors because LAG requires a PARTITION BY clause when the table has a grouping column
  • B. It silently computes growth across region-interleaved rows, so LAG pulls the prior row which may belong to a different region, producing meaningless growth values ✓
  • C. It automatically partitions by region because region is a column in the table
  • D. It returns NULL for every row because ORDER BY month alone is not a valid window frame
Correct answer: B. Without PARTITION BY region, the window is the whole result set ordered by month, so LAG crosses region boundaries and yields incorrect cross-region growth rather than erroring.
An XGBoost model's training logloss keeps decreasing across 2000 boosting rounds, but validation logloss bottomed at round 300 and has risen since. A teammate proposes lowering the learning rate from 0.1 to 0.01 while keeping n_estimators=2000 fixed and no early stopping. What is the most likely result?
  • A. Lower learning rate alone eliminates overfitting because each tree contributes less, so validation loss will keep improving to round 2000
  • B. It still overfits: a smaller learning rate needs MORE rounds to fit, but with 2000 rounds and no early stopping it will again overshoot the optimal round and overfit ✓
  • C. Training loss will stop decreasing, proving the model can no longer fit the data
  • D. The two hyperparameters are independent, so learning rate has no effect on where validation loss bottoms out
Correct answer: B. Learning rate and n_estimators trade off; shrinking the rate slows fitting but with a fixed large round count and no early stopping the ensemble still passes the optimal point and overfits, so early stopping on validation is the real fix.
A deep network trains stably at batch size 256 with Adam and lr=1e-3. After switching to SGD with the SAME lr=1e-3 and batch size 2048, loss diverges to NaN within a few steps. Which explanation is most consistent with this?
  • A. Adam adapts per-parameter step sizes so 1e-3 was safe, but raw SGD applies that lr directly to large gradients, and the 8x larger batch also raises the effective step, causing divergence ✓
  • B. SGD is fundamentally unable to train deep networks, so any lr will diverge
  • C. Larger batch size always reduces the effective learning rate, so the divergence must come from a data pipeline bug, not the optimizer change
  • D. Adam and SGD are interchangeable at the same lr; the NaN must be from float16 overflow unrelated to the optimizer swap
Correct answer: A. Adam normalizes updates by gradient magnitude so a given lr behaves very differently under plain SGD, and a larger batch gives lower-variance but not smaller-magnitude gradients, so the un-normalized step is far too large and diverges.
An offline-trained churn model scores AUC 0.88 on a held-out test set but only 0.71 in production two weeks after launch. Feature distributions (PSI) are stable, and no schema changed. The training set was built by joining a snapshot that included a 'days_since_last_login' feature computed as of the label date. What is the most probable root cause?
  • A. Concept drift: customer behavior changed in two weeks, so retrain more frequently
  • B. Covariate shift: the PSI test is too weak to detect the shift, so use the KS test instead
  • C. Temporal/target leakage: the feature was computed using information from at or after the label window, so it is unavailable or different at true serving time, inflating offline AUC ✓
  • D. Sample ratio mismatch between training and serving traffic caused the degradation
Correct answer: C. Stable input distributions plus a big offline-to-online drop and a feature computed 'as of the label date' point to temporal leakage where offline features encode future information unavailable at serving time.
A team runs an A/B test, checks the p-value daily, and stops the moment it drops below 0.05 on day 6 of a planned 14-day test, declaring a win. Assuming no true effect, what is the primary statistical problem?
  • A. Nothing is wrong; reaching p<0.05 earlier just means the effect is strong enough to stop early
  • B. Repeated peeking inflates the Type I error rate far above 5% because each look is another chance to cross the threshold by noise; a sequential/alpha-spending procedure is required to stop early validly ✓
  • C. The test is underpowered, so the p-value is unreliable and they should have used a larger sample from the start
  • D. Daily checks reduce power, making a false negative (Type II error) the main risk here
Correct answer: B. Optional stopping on a fixed-horizon p-value multiplies the chances of a false positive so the real Type I rate greatly exceeds 5%; valid early stopping needs sequential testing or alpha-spending.
In scaled dot-product attention, scores are computed as softmax(QK^T / sqrt(d_k)) V. Why is the division by sqrt(d_k) present, and what breaks without it as d_k grows large?
  • A. It normalizes the output to unit norm; without it the output magnitude grows and the residual connection overflows
  • B. For large d_k the dot products have large variance, pushing softmax into saturated regions with vanishing gradients; scaling by sqrt(d_k) keeps score variance ~1 so gradients stay usable ✓
  • C. It converts logits to probabilities; without it softmax cannot be applied at all
  • D. It makes attention permutation-invariant; without it positional information leaks into the scores
Correct answer: B. With random Q,K the dot product variance scales with d_k, so unscaled logits saturate softmax and kill gradients; dividing by sqrt(d_k) keeps the variance around 1 and preserves gradient flow.
You must add a feature answering internal-policy questions over a 40,000-page compliance manual that is revised weekly, with a hard requirement that every answer cite the exact source paragraph and that removed documents stop being answerable immediately. Which approach best fits, and why?
  • A. Fine-tune the base model weekly on the manual, because fine-tuning gives the best factual grounding and lowest latency
  • B. RAG over a vector index of the manual, because retrieval provides citable source chunks, weekly revisions only require re-indexing (not retraining), and deleting a document removes it from answers immediately ✓
  • C. A long-context prompt stuffing all 40,000 pages every call, because it guarantees the model sees everything and needs no infrastructure
  • D. Fine-tune with LoRA adapters daily, because adapters are cheap and encode citations directly into the weights
Correct answer: B. RAG naturally supplies verifiable source passages for citation, handles frequent updates by re-indexing rather than retraining, and honors deletions instantly by removing chunks from the index, which fine-tuning and full-context stuffing cannot do cleanly or affordably.
An analyst finds users who enabled two-factor auth churn 30% less and recommends forcing 2FA on everyone to cut churn. What is the strongest methodological objection?
  • A. The sample is too small unless it exceeds 30 users per the Central Limit Theorem
  • B. Self-selection/confounding: users who opt into 2FA are already more engaged and security-conscious, so the correlation likely reflects that confounder rather than a causal effect of 2FA on churn ✓
  • C. The p-value was not reported, so the 30% figure is meaningless regardless of design
  • D. Churn is a lagging metric, so any observational finding about it is automatically invalid
Correct answer: B. 2FA adoption is voluntary and correlates with engagement, a classic confounder, so the observed reduction cannot be read as causal without a randomized rollout or a valid quasi-experimental design.
You deploy LoRA fine-tuning: the base weights W are frozen and you learn a low-rank update so the effective weight is W + (B A) with A (r x d) and B (d x r), rank r=8. Which statement about this setup is correct?
  • A. LoRA modifies the frozen W in place during training, so you must keep a full copy of the original weights to roll back
  • B. Only A and B are trained, drastically cutting trainable parameters and optimizer state; at inference B A can be merged into W so there is no added latency ✓
  • C. LoRA requires 4-bit quantization of the base model to function; without QLoRA the low-rank update is mathematically undefined
  • D. The rank r must equal the hidden dimension d for the approximation to be lossless, so r=8 will always underfit badly
Correct answer: B. LoRA freezes W and trains only the small A and B matrices (huge memory savings on params and optimizer state), and since BA has the same shape as W it can be folded into the weights at inference for zero added latency.

Prep for another role

Questions are original, written and independently verified for HireHire's role interview quizzes. They reflect the kind of knowledge Data Scientist interviews test, not any specific company's questions. HireHire maps live tech & IT jobs across India, updated regularly. Last updated: July 2026.