Data preparation and leakage
Build reproducible transformations without contaminating evaluation.
Fit preprocessing on training data only and apply the fitted transformations to validation and test.
Interview questions
Choose a question to reveal its answer.
01EasyCoreHow do you handle missing values without leaking test data?
Answer
How do you handle missing values without leaking test data?
Fills missing values using a specified rule learned on appropriate data.
Replace missing income using the training median.
02EasyCoreWhen should you standardize input features?
Answer
When should you standardize input features?
Subtracts training mean and divides by training standard deviation.
Scale inputs for a distance-based classifier.
03EasyCoreHow do you encode nominal categorical variables?
Answer
How do you encode nominal categorical variables?
Represents categories with indicator columns.
Convert unordered color labels into numeric features.
04MediumHigh priorityShould you always remove outliers?
Answer
Should you always remove outliers?
Observation unusually far from the typical data distribution; not necessarily an error.
Investigate a very large transaction before deciding to remove it.
05MediumHigh priorityWhat is data leakage and how do you prevent it?
Answer
What is data leakage and how do you prevent it?
Use of information unavailable at prediction time or from held-out data during training.
Fit imputers, scalers, feature selectors and resampling only inside training folds. Also inspect time-dependent features, duplicates and features derived from the target. Leakage can produce impressive but misleading validation scores.
Fit an imputer on all records before splitting and obtain overly optimistic evaluation.
06MediumWhy use stratified train-test splits?
Answer
Why use stratified train-test splits?
Preserves class proportions approximately across splits.
Keep rare positive cases represented in training and test.
07MediumGive an example of useful feature engineering.
Answer
Give an example of useful feature engineering.
Creates useful representations from raw inputs using domain knowledge.
Derive elapsed days from a timestamp available at prediction time.
08MediumHow does feature selection differ from feature extraction?
Answer
How does feature selection differ from feature extraction?
Chooses a subset of original variables.
Remove irrelevant columns to simplify a model.
09HardWhen should SMOTE be applied during cross-validation?
Answer
When should SMOTE be applied during cross-validation?
Creates synthetic minority examples by interpolating nearby minority samples; apply only within training folds.
Address class imbalance without contaminating the validation set.
10HardWhy use an sklearn pipeline?
Answer
Why use an sklearn pipeline?
Chains fitted preprocessing and modeling steps consistently.
Cross-validate scaling and a classifier as one estimator.
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
model = make_pipeline(StandardScaler(), LogisticRegression())
# Fit model on training data only.A pipeline keeps fitted preprocessing inside cross-validation.
11MediumHigh priorityHow does min-max scaling differ from standardization?
Answer
How does min-max scaling differ from standardization?
Linearly rescales features using fitted extrema; new values can exceed the training range.
Rescale a bounded input feature based only on training minimum and maximum.
12MediumHigh priorityWhen is robust scaling preferable to standard scaling?
Answer
When is robust scaling preferable to standard scaling?
Centers using the median and scales using a quantile range, often the interquartile range.
Scale financial features with extreme values.
13MediumHigh priorityHow do you avoid leakage in target encoding?
Answer
How do you avoid leakage in target encoding?
Represents categories using statistics of the target, requiring leakage-aware estimation.
Encode high-cardinality categories with out-of-fold target means.
14MediumHigh priorityWhen can missing values themselves be predictive?
Answer
When can missing values themselves be predictive?
Binary feature recording whether a value was missing before imputation.
Let a model learn whether missing lab measurements carry information.
15MediumHigh priorityWhy use group-based splits instead of random splits?
Answer
Why use group-based splits instead of random splits?
Keeps observations belonging to the same group in the same partition.
Ensure records from a patient do not appear in both training and test.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.
1. When should a scaler be fitted during five-fold cross-validation?
2. What is a safe approach to SMOTE with cross-validation?
3. A dataset contains multiple records per patient. Which split best avoids patient overlap?
EDA and feature diagnostics
Continue to the next set of interview questions.