Problem 3: Plot Train and Test Error Across Increasing Model Complexity
Easypython
Learn the Concept: Bias-Variance TradeoffProblem Description
Write a Python program that trains Decision Trees with max_depth ranging from 1 to 15, plotting both training and test error against max_depth to visualize the bias-variance tradeoff.
Input
A dataset split into training and test sets.
Output
A displayed chart showing train and test error curves across increasing max_depth.
Constraints
- At least 30 data points total.
Example Input
text(A dataset with 30 points, split into train/test)
Example Output
text(A line chart showing training error steadily decreasing, and test error initially decreasing then increasing — the classic bias-variance U-shape for test error)
Concepts Covered
Looping over max_depth, plt.plot(), visualizing the tradeoff.
Related Problems
- Problem 1: Compare Train vs Test Error for a Simple ModelEasy · pythonSolve Problem
- Problem 2: Compare Train vs Test Error for an Overly Complex ModelEasy · pythonSolve Problem
- Problem 4: Identify the Best max_depth Using Test ErrorEasy · pythonSolve Problem