Skip to content
CampusEduX

Problem 1: Compare Train vs Test Error for a Simple Model

Easypython
Learn the Concept: Bias-Variance Tradeoff

Problem Description

Write a Python program that trains a very shallow Decision Tree (max_depth=1) on a dataset and compares its training error to its test error, to observe signs of high bias.

Input

A dataset split into training and test sets.

Output

Training and test MSE for the shallow model.

Constraints

  • The underlying data should have a non-trivial (non-linear) pattern.

Example Input

text
(A dataset with a clear non-linear pattern, split into train/test)

Example Output

text
Train MSE: 0.38 Test MSE: 0.41

Concepts Covered

DecisionTreeRegressor, max_depth, mean_squared_error().

Related Problems

  • Problem 2: Compare Train vs Test Error for an Overly Complex Model
    Easy · python
    Solve Problem
  • Problem 3: Plot Train and Test Error Across Increasing Model Complexity
    Easy · python
    Solve Problem
  • Problem 4: Identify the Best max_depth Using Test Error
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...