You want to tune max_depth and learning_rate for XGBoost without overfitting to the test set. What is the right setup?
- Exam domain
- Machine Learning With RAPIDS16% of the exam
- Difficulty
- Medium
- In this mock
- 8 questions on this domainPractise this domain
Why the exam asks this
Machine Learning With RAPIDS (16% of the exam)
Objective in the exam guide: Hyperparameter tuning and optimization
Tuning and cross-validation are separate objectives that go together.
Why C is the answer
Tune with cross-validation on training data, then test once
Hyperparameters should be chosen with validation data or cross-validation. The test set is used once at the end for an unbiased estimate.
Remember: Tune with CV; test once.
How it works
Hyperparameter tuning uses grid, random or Bayesian search with cross-validation.
In detail
- Tune on validation or CV.
- Test once at the end.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Tune on the test set directly, since it is the most realistic data you have availableWrongMost tempting
Tuning on test data leaks it.
Why it tempts: The test set feels most realistic.
B. Tune on training accuracy aloneWrong
Training accuracy rewards overfitting.
C. Tune with cross-validation on training data, then test onceRight
Tune with CV; test once.
D. Pick the defaults and skip tuningWrong
Defaults may be far from optimal.
Use case
An illustrative scenario, not a real incident.
Illustrative: a random search over 40 settings with 5-fold CV finds depth 6 and learning rate 0.05.
See it in different ways
flowchart LR S0["Split train and test"] --> S1["Cross-validate settings on train"] --> S2["Pick best"] --> S3["Retrain on train"] --> S4["Test once"]
How to read this chart
- Read it in order: Split train and test, then Cross-validate settings on train, then Pick best, then Retrain on train, then Test once.
mindmap
root(("Tuning"))
n1["Grid"]
n2["All combinations"]
n3["Random"]
n4["Sampled settings"]
n5["Bayesian"]
n6["Guided by past trials"]How to read this chart
- The centre is "Tuning".
- "Grid" covers "All combinations".
- "Random" covers "Sampled settings".
- "Bayesian" covers "Guided by past trials".
Related questions
Learn more
- Our lesson: Machine learning with RAPIDS
- Practise Machine Learning With RAPIDS questions in the mock exam
- Source: Tuning the hyper-parameters of an estimator (scikit-learn)
- Source: Cross-validation (scikit-learn)
- cuML documentation (RAPIDS)
- XGBoost GPU support
- Cross-validation (scikit-learn)
- Metrics and scoring (scikit-learn)