QUIZ
Data and features
5 questions on Data and features, from 4 lessons. Pick an answer in your head, then open it.
On the roadmap for: ML Engineering, Data Science.
Question 1 of 5
You encode a high-cardinality feature (e.g. 400 pincodes) by each pincode's average target value. What's the risk, and the fix?
- A. Too many new columns: one for each of the 400 pincodes in the data
- B. It only works for tree models, not linear ones
- C. None: target encoding is always safe to use
- D. Leakage from each row's own label; compute it out-of-fold
View answer
✓ D. Leakage from each row's own label; compute it out-of-fold
Out-of-fold target encoding uses only other rows' labels, so the model can't read its own answer.
Lesson: Encoding Categorical Features
Question 2 of 5
Some values are missing, and whether a value is missing may itself mean something. What should you do?
- A. Drop every row that has a missing value
- B. Fill it with zero and add nothing else
- C. Impute it and add a 'was missing' indicator
- D. Remove the feature from the model entirely
View answer
✓ C. Impute it and add a 'was missing' indicator
Missingness is often informative, like slow kitchens not reporting prep time; the indicator lets the model use it.
Lesson: Missing Values & Feature Scaling
Question 3 of 5
Which model is largely unaffected by feature scaling?
- A. Decision trees and tree ensembles
- B. k-nearest neighbours
- C. Logistic regression with L2 regularisation
- D. Neural networks
View answer
✓ A. Decision trees and tree ensembles
Trees split on thresholds, so rescaling a feature doesn't change the splits. Distance-based and gradient-trained models need scaling.
Lesson: Missing Values & Feature Scaling
Question 4 of 5
You build a 'customer's average order value' feature to predict churn. How do you avoid leaking the future?
- A. Use only data available before the prediction time
- B. Use all of the customer's orders, past and future
- C. Use the test set's averages so it matches evaluation
- D. It can't leak, because it's only an average
View answer
✓ A. Use only data available before the prediction time
Point-in-time correct features match what the model will actually see in production.
Lesson: Feature Engineering
Question 5 of 5
Where must feature selection happen when you cross-validate?
- A. Inside each training fold, as part of the pipeline
- B. Once on the whole dataset, before cross-validation
- C. After choosing the final model
- D. Only on the test set, after training
View answer
✓ A. Inside each training fold, as part of the pipeline
Selecting features with all the labels first leaks validation information and inflates the score.
Lesson: Feature Selection