Skip to content
C

Problem 3: Plot Train and Test Error Across Increasing Model Complexity

Easypython

Problem 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.

Input (stdin)

Output

Run your code to see output here...