Skip to content
CampusEduX

Problem 2: Compare Trees of Different Depths

Easypython
Learn the Concept: Decision Trees

Problem Description

Write a Python program that trains Decision Trees with max_depth=1, max_depth=3, and no depth limit on the same dataset, then compares their predictions on the same new data point.

Input

A labeled dataset and one new data point.

Output

The prediction from each of the three trees.

Constraints

  • At least 8 labeled training examples.

Example Input

text
X=[[1],[2],[3],[7],[8],[9],[10],[11]], y=[0,0,0,1,1,1,1,1], new=[[6]]

Example Output

text
max_depth=1: [1] max_depth=3: [0] No limit: [0]

Concepts Covered

max_depth parameter, comparing model configurations.

Related Problems

  • Problem 1: Train a Basic Decision Tree Classifier
    Easy · python
    Solve Problem
  • Problem 3: Manually Calculate Gini Impurity
    Easy · python
    Solve Problem
  • Problem 4: Visualize a Trained Decision Tree
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...