Problem 3: Find a Well-Balanced Model
Easypython
Learn the Concept: Overfitting & UnderfittingProblem Description
Write a Python program that tests several max_depth values and identifies which one produces the SMALLEST gap between training and test MSE (as a simple way of finding a well-balanced model).
Input
A dataset split into train/test, and a range of max_depth values to test.
Output
The max_depth value with the smallest train-test performance gap.
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 balanced max_depth: 3 Train MSE: 0.05, Test MSE: 0.06 (gap: 0.01)
Concepts Covered
Looping, gap calculation, model comparison.
Related Problems
- Problem 1: Demonstrate UnderfittingEasy · pythonSolve Problem
- Problem 2: Demonstrate OverfittingEasy · pythonSolve Problem
- Problem 4: Diagnose a Model Given Only Its ScoresEasy · pythonSolve Problem