Scikit-learn

Visualize Decision Tree

Please select your Decision Tree and visualize it. Visualization works for classifier and regressor trees. You can set max depth of visualization in Advanced options. Please be aware that tree deeper than 5 levels are not readable. For better visualization, please train shallow tree or limit max depth during visualization.

decision-tree

Required packages

You need below packages to use the code generated by recipe. All packages are automatically installed in MLJAR Studio.

scikit-learn>=1.5.0

matplotlib>=3.8.4

Interactive recipe

You can use below interactive recipe to generate code. This recipe is available in MLJAR Studio.

In the below recipe, we assume that you have following variables available in your notebook:

  • my_classifier (type DecisionTreeClassifier)
  • my_regressor (type DecisionTreeRegressor)
  • X (type DataFrame)
  • y (type Series)

Python code

# Python code will be here

Code explanation

Creates matplotlib figure with Decision Tree visualization.