179 questions
No questions match those filters.
You have 15% missing values in a numeric column. How do...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansSplit first, always. Computing any statistic — a mean, a median, a mode — across the full dataset before splitting means your imputation has already encoded information from the test set. That’s a leak, and it makes validation quietly optimistic in a way production later corrects, painfully, once real unseen data behaves differently from what the leaked statistic predicted.
The correct order: split into train/validation/test first, compute the imputation parameters (mean, median, whatever the strategy is) on the training fold only, then apply those same fixed parameters to validation and test. Same discipline applies to scaling and encoding — anything derived from the data needs to be fit on train only.
In practice I put this in a pipeline object (scikit-learn’s Pipeline
or equivalent) specifically so it can’t be done wrong by hand later by
someone re-running the notebook out of order.