Skip to content
C

Problem 4: Visualize a Trained Decision Tree

Easypython

Problem Description

Write a Python program that trains a Decision Tree on a small dataset and visualizes its structure using plot_tree().

Input

A small labeled dataset with feature names.

Output

A displayed tree diagram showing the learned splitting rules.

Constraints

  • At least 6 labeled training examples with 2 features.

Example Input

text
X=[[1,60],[2,65],[8,95],[9,98]], y=[0,0,1,1], feature_names=["hours_studied","attendance"]

Example Output

text
(A tree diagram window showing the learned decision splits, feature names, and class labels)

Concepts Covered

DecisionTreeClassifier, plot_tree().

Input (stdin)

Output

Run your code to see output here...