Question 1Easy
In k-fold cross-validation, the data is
- Split into two equal parts only
- Duplicated k times and evaluated on the same split each round
- Sorted by label and then split
- Split into k parts; each part is used once as validation while the rest train
Answer: D. Split into k parts; each part is used once as validation while the rest train
Explanation
Each of the k folds acts as the validation set exactly once, and the k scores are averaged.
Step-by-step solution
- Divide data into k folds.
- Train on k-1, validate on 1.
- Repeat k times and average.
Why the other options are wrong
- A. That is a single hold-out split.
- B. Folds differ each round.
- C. Sorting by label would break representativeness.
Question 2Medium
Stratified k-fold is preferred for classification with imbalanced classes because it
- Removes the minority class
- Increases k automatically
- Shuffles the labels randomly between folds to remove any bias
- Keeps the class proportions similar in every fold
Answer: D. Keeps the class proportions similar in every fold
Explanation
Without stratification a fold may hold almost no minority samples, giving unstable scores.
Step-by-step solution
- Count each class.
- Split each class across folds evenly.
- Every fold mirrors the full data.
Why the other options are wrong
- A. It keeps minority samples in all folds.
- B. k is chosen by you.
- C. Labels are not shuffled; rows are distributed by class.
Question 5Medium
Why should the test set not be used to tune hyperparameters?
- The test set is always too small
- It leaks information, making the final score over-optimistic
- Hyperparameters cannot be tuned on any kind of data at all
- It makes the model underfit
Answer: B. It leaks information, making the final score over-optimistic
Explanation
If you pick settings by looking at test performance, the test set stops being unseen and no longer estimates real-world performance.
Step-by-step solution
- Tune on validation or CV folds.
- Touch the test set only once at the end.
- Otherwise the estimate is biased upwards.
Why the other options are wrong
- A. Size is not the issue; leakage is.
- C. They are tuned on a validation set or CV.
- D. Leakage causes optimistic estimates, not underfitting.
Question 6Hard
Which is a data-leakage mistake?
- Fitting a scaler on the full dataset before splitting into train and test
- Fitting a scaler on the training data and applying it to the test data
- Using stratified splits
- Holding out a validation set
Answer: A. Fitting a scaler on the full dataset before splitting into train and test
Explanation
Computing mean and standard deviation on all rows lets test-set statistics influence training; fit on train only.
Step-by-step solution
- Split first.
- Fit the scaler on train only.
- Transform both train and test with it.
Why the other options are wrong
- B. This is the correct procedure.
- C. Stratification does not leak test information.
- D. Holding out data is the opposite of leakage.