Problem 4: Visualize a Trained Decision Tree
Easypython
Learn the Concept: Decision TreesProblem 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
textX=[[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().
Related Problems
- Problem 1: Train a Basic Decision Tree ClassifierEasy · pythonSolve Problem
- Problem 2: Compare Trees of Different DepthsEasy · pythonSolve Problem
- Problem 3: Manually Calculate Gini ImpurityEasy · pythonSolve Problem