How do you handle missing values in a dataset?
What the interviewer wants to hear
- First understand why data is missing
- Options: drop, impute (mean, median, model), or flag
- Missingness itself can be informative
- Fit imputation on training data only
Model answer
First I find out how much is missing and why. If a value is missing because of a tracking bug on one app version, that is a data quality issue to fix, not just fill. If it is missing for a reason, like "last purchase date" being empty for users who never bought, the missingness itself carries meaning. Then I choose. If very few rows are affected and they look random, dropping them may be fine. For numeric features I often impute the median and add a binary "was missing" flag so the model can learn from it. For categories I add an "unknown" value. Sometimes model-based imputation helps. Many tree models handle missing values directly. For modelling, I fit any imputation on the training set only, to avoid leakage, and check that results do not change much with different choices.
Can you answer it under time pressure?
Take a timed easy round and get scored on every answer.
More easy Data Scientist questions
- Explain what a p-value is to a product manager, and one common way it is misunderstood.
- When would you report the median instead of the mean? Give a business example.
- What is the difference between correlation and causation? How would you test if a change causes an outcome?
- How do you present a data analysis to non-technical stakeholders?
- Explain the trade-off between precision and recall, and how you would pick a threshold for a real model.
- What is the central limit theorem and why does it matter for everyday analysis work?
- You receive a new, messy dataset for an analysis. What are your first steps before any modelling?
- How do you choose the right chart to present a finding to senior leaders?
- Why do we split data into training, validation and test sets? How do you decide how to split?