supertree
- Interactive Decision Tree Visualizationsupertree
is a Python package designed to visualize decision trees in an interactive 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:
Check this features in example directory :)
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris
from supertree import SuperTree # <- import supertree :)
# Load the iris dataset
iris = load_iris()
X, y = iris.data, iris.target
# Train model
model = DecisionTreeClassifier()
model.fit(X, y)
# Initialize supertree
super_tree = SuperTree(model, X, y, iris.feature_names, iris.target_names)
# show tree in your notebook
super_tree.show_tree()
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.
You can install SuperTree package using pip:
pip install supertree
Conda support coming soon.
sklearn
)The package is compatible with a wide range of classifiers and regressors from these libraries, specifically:
DecisionTreeClassifier
ExtraTreeClassifier
ExtraTreesClassifier
RandomForestClassifier
GradientBoostingClassifier
HistGradientBoostingClassifier
DecisionTreeRegressor
ExtraTreeRegressor
ExtraTreesRegressor
RandomForestRegressor
GradientBoostingRegressor
HistGradientBoostingRegressor
LGBMClassifier
LGBMRegressor
Booster
XGBClassifier
XGBRFClassifier
XGBRegressor
XGBRFRegressor
Booster
If we do not support the model you want to use, please let us know.
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: