Skip to content
C

Problem 3: Find a Well-Balanced Model

Easypython

Problem 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_depth values from 1 to 10.

Example Input

text
(A dataset split into train/test, testing max_depth 1 through 10)

Example Output

text
Best balanced max_depth: 3 Train MSE: 0.05, Test MSE: 0.06 (gap: 0.01)

Concepts Covered

Looping, gap calculation, model comparison.

Input (stdin)

Output

Run your code to see output here...