Problem 4: Identify the Best max_depth Using Test Error
Easypython
Problem Description
Write a Python program that trains Decision Trees across a range of max_depth values, and identifies which value produces the LOWEST test error (a simple, manual approach to finding a good complexity balance).
Input
A dataset split into training and test sets, and a range of max_depth values to try.
Output
The max_depth value that produced the lowest test error, along with that error value.
Constraints
- Test
max_depthvalues from 1 to 10.
Example Input
text(A dataset split into train/test, testing max_depth 1 through 10)
Example Output
textBest max_depth: 4 Test MSE at best depth: 0.15
Concepts Covered
Looping, tracking minimum error, DecisionTreeRegressor.