- Notifications
You must be signed in to change notification settings - Fork19
Visualize decision trees in Python
License
mljar/supertree
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
supertree is a Python package designed to visualize decision trees in aninteractive and user-friendly way within Jupyter Notebooks, Jupyter Lab, Google Colab, and any other notebooks that support HTML rendering. With this tool, you can not only display decision trees, but also interact with them directly within your notebook environment. Key features include:
- ability to zoom and pan through large trees,
- collapse and expand selected nodes,
- explore the structure of the tree in an intuitive and visually appealing manner.
fromsklearn.treeimportDecisionTreeClassifierfromsklearn.datasetsimportload_irisfromsupertreeimportSuperTree# <- import supertree :)# Load the iris datasetiris=load_iris()X,y=iris.data,iris.target# Train modelmodel=DecisionTreeClassifier()model.fit(X,y)# Initialize supertreesuper_tree=SuperTree(model,X,y,iris.feature_names,iris.target_names)# show tree in your notebooksuper_tree.show_tree()
fromsklearn.ensembleimportRandomForestRegressorfromsklearn.datasetsimportload_diabetesfromsupertreeimportSuperTree# <- import supertree :)# Load the diabetes datasetdiabetes=load_diabetes()X=diabetes.datay=diabetes.target# Train modelmodel=RandomForestRegressor(n_estimators=100,max_depth=3,random_state=42)model.fit(X,y)# Initialize supertreesuper_tree=SuperTree(model,X,y)# show tree with index 2 in your notebooksuper_tree.show_tree(2)
There are more code snippets in theexamples directory.
You can install SuperTree package using pip:
pip install supertreeConda support coming soon.
- scikit-learn (
sklearn) - LightGBM
- XGBoost
- ONNX:
The package is compatible with a wide range of classifiers and regressors from these libraries, specifically:
DecisionTreeClassifierExtraTreeClassifierExtraTreesClassifierRandomForestClassifierGradientBoostingClassifierHistGradientBoostingClassifierDecisionTreeRegressorExtraTreeRegressorExtraTreesRegressorRandomForestRegressorGradientBoostingRegressorHistGradientBoostingRegressor
LGBMClassifierLGBMRegressorBooster
XGBClassifierXGBRFClassifierXGBRegressorXGBRFRegressorBooster
If we do not support the model you want to use, please let us know.
![]() See all the details | ![]() Zoom |
![]() Fullscreen in Jupyter | ![]() Depth change |
![]() Color change | ![]() Navigate in forest |
![]() Show specific sample path | ![]() Save tree to svg |
![]() Links sample visualization | ![]() Showing the path to the leaf |
Check this features in example directory :)
- Visualize decision tree from scikit-learn package
- 4 ways to vizualize decision tree from LightGBM
- How to visualize decision tree from Xgboost
If you encounter any issues, find a bug, or have a feature request, we would love to hear from you! Please don't hesitate to reach out to us at supertree/issues. We are committed to improving this package and appreciate any feedback or suggestions you may have.
supertree is a commercial software with two licenses available:
- AGPL-3.0 license
- Commercial license with support and maintenance included. Pricing websitehttps://mljar.com/supertree/ Licensesupertree-commercial-license.pdf.
About
Visualize decision trees in Python
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.












