Skip to main content

supertree - Interactive Decision Tree Visualization

License PyPI version Downloads GitHub stars

Visualize decision trees interactively in Jupyter, JupyterLab, and Google Colab. Zoom, pan, collapse nodes, and trace sample paths - all inside your notebook.

Works with scikit-learn, XGBoost, LightGBM, and ONNX.

Installation

pip install supertree

Quick Start

Visualize Decision Tree classifier on iris data

Open In Colab
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris
from supertree import SuperTree

# Load the iris dataset
iris = load_iris()

# Train model
model = DecisionTreeClassifier(max_depth=3)
model.fit(iris.data, iris.target)

# Initialize supertree
super_tree = SuperTree(model, iris.data, iris.target, iris.feature_names, iris.target_names)

# show tree in your notebook
super_tree.show_tree()

It works with trees ensembles too - Random Forest Regressor Example

Open In Colab
from sklearn.ensemble import RandomForestRegressor
from sklearn.datasets import load_diabetes
from supertree import SuperTree  # <- import supertree :)

# Load the diabetes dataset
diabetes = load_diabetes()
X = diabetes.data
y = diabetes.target

# Train model
model = RandomForestRegressor(n_estimators=100, max_depth=3, random_state=42)
model.fit(X, y)

# Initialize supertree
super_tree = SuperTree(model,X, y)
# show tree with index 2 in your notebook
super_tree.show_tree(2)

There are more code snippets in the examples directory.

Supported Libraries

  • scikit-learn (sklearn)
  • LightGBM
  • XGBoost
  • ONNX:

Supported Algorithms

The package is compatible with a wide range of classifiers and regressors from these libraries, specifically:

Scikit-learn

  • DecisionTreeClassifier
  • ExtraTreeClassifier
  • ExtraTreesClassifier
  • RandomForestClassifier
  • GradientBoostingClassifier
  • HistGradientBoostingClassifier
  • DecisionTreeRegressor
  • ExtraTreeRegressor
  • ExtraTreesRegressor
  • RandomForestRegressor
  • GradientBoostingRegressor
  • HistGradientBoostingRegressor

LightGBM

  • LGBMClassifier
  • LGBMRegressor
  • Booster

XGBoost

  • XGBClassifier
  • XGBRFClassifier
  • XGBRegressor
  • XGBRFRegressor
  • Booster

If we do not support the model you want to use, please let us know.

Articles

Support

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.

License

supertree is open source under the Apache License 2.0.

Metadata

Release files for supertree 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for supertree 1.1.0
File Interpreter ABI Platform
supertree-1.1.0-py3-none-any.whl Python 3 none any Details

Release files / supertree-1.1.0-py3-none-any.whl

Download URL supertree-1.1.0-py3-none-any.whl
Size 299.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd4021ccb01229ea43c8b59bdb9dcc5484d6507d78153a6b8b8fb7caba202c5f
BLAKE2b-256 checksum
How to use checksums
c0cf286d83f61e071b4ba14dadd1a937f5fac61d222a1a2263cd65b7ab2d462d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.5

Security for supertree 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page