Data Science Data Wrangling and Preprocessing 3 — Questions and Answers
Question 1: A feature ranges from 0 to 1,000,000 while another ranges from 0 to 1. Which preprocessing step puts them on a comparable scale?
- Feature scaling (normalization/standardization) (Correct answer)
- One-hot encoding
- Deduplication
- Tokenization
Correct answer: Feature scaling (normalization/standardization)
Scaling transforms features to comparable ranges so models relying on distance aren't dominated by large-magnitude features.
Question 2: Min-max scaling transforms a feature to which range by default?
- [0, 1] (Correct answer)
- [-1, 1]
- Mean 0, std 1
- [0, 100]
Correct answer: [0, 1]
Min-max scaling maps the minimum to 0 and the maximum to 1 using (x - min)/(max - min).
Question 3: Standardization (z-score) rescales a feature to have what properties?
- Mean 0 and standard deviation 1 (Correct answer)
- Min 0 and max 1
- Sum equal to 1
- Median 0 and IQR 1
Correct answer: Mean 0 and standard deviation 1
Z-score standardization subtracts the mean and divides by the standard deviation, yielding mean 0 and unit variance.
Question 4: When encoding a nominal categorical variable with no inherent order, which method avoids implying a false ranking?
- One-hot encoding (Correct answer)
- Label/ordinal encoding
- Min-max scaling
- Log transform
Correct answer: One-hot encoding
One-hot encoding creates a binary column per category, avoiding the implied ordering that integer label encoding introduces.
Question 5: A right-skewed feature like website session duration is transformed with a log. What is the main benefit?
- It reduces skewness and compresses large values (Correct answer)
- It removes all missing data
- It converts it to categorical
- It guarantees a uniform distribution
Correct answer: It reduces skewness and compresses large values
A log transform compresses the long right tail, reducing skewness and lessening the influence of extreme values.
Question 6: Why should scaling parameters be computed only on the training set, then applied to the test set?
- To prevent data leakage from the test set (Correct answer)
- To make the test set larger
- To remove duplicates
- To convert types
Correct answer: To prevent data leakage from the test set
Fitting the scaler on training data only prevents test-set statistics from leaking into the model and inflating performance.
Question 7: Which scaling method is most robust when a feature contains many extreme outliers?
- RobustScaler (uses median and IQR) (Correct answer)
- Min-max scaling
- Standard scaling
- Unit-vector scaling
Correct answer: RobustScaler (uses median and IQR)
RobustScaler centers on the median and scales by the interquartile range, making it resistant to outliers.
A feature ranges from 0 to 1,000,000 while another ranges from 0 to 1.
Which preprocessing step puts them on a comparable scale?