dtreeviz
Enrichment pendingA python library for decision tree visualization and model interpretation.
GraphCanon updated today · GitHub synced today
Trust & integrity
Full report- Maintenance
- Slowing (190d since push)
- As of today · Source: github_public_v1
- Provenance
- Not a fork · Personal account
- As of today · Source: github_public_v1
- Security (OSV)
- No lockfile
- As of today · Source: none
Public GitHub metadata and optional OSV dependency scans. Signals, not a guarantee. Trust methodology.
Overview
A python library for decision tree visualization and model interpretation.
Capability facts
- Languages
- jupyter notebook
Source: github.language · Jul 11, 2026
Categories
Compatibility
Sourced claims from the README excerpt - not unsourced marketing copy.
Source: README excerpt (regex_v1, Jul 11, 2026)
Here's a complete example Python file that displays the following tree in a popup window:Source link
Tags
README
Quick start
See Installation instructions then take a look at the specific notebooks for the supported ML library you're using:
- sklearn-based examples (colab)
- LightGBM-based examples (colab)
- Spark-based examples (colab)
- TensorFlow-based examples (colab) Also see blog at tensorflow.org Visualizing TensorFlow Decision Forest Trees with dtreeviz
- XGBoost-based examples (colab)
- Classifier decision boundaries for any scikit-learn model.ipynb (colab)
- Changing colors notebook (colab)
- AI-powered tree analysis (sklearn) - Interactive chat and explanations using LLMs
To interopt with these different libraries, dtreeviz uses an adaptor object, obtained from function dtreeviz.model(), to extract model information necessary for visualization. Given such an adaptor object, all of the dtreeviz functionality is available to you using the same programmer interface. The basic dtreeviz usage recipe is:
- Import dtreeviz and your decision tree library
- Acquire and load data into memory
- Train a classifier or regressor model using your decision tree library
- Obtain a dtreeviz adaptor model using
viz_model = dtreeviz.model(your_trained_model,...) - Call dtreeviz functions, such as
viz_model.view()orviz_model.explain_prediction_path(sample_x)
Example
Here's a complete example Python file that displays the following tree in a popup window:
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
import dtreeviz
iris = load_iris()
X = iris.data
y = iris.target
clf = DecisionTreeClassifier(max_depth=4)
clf.fit(X, y)
viz_model = dtreeviz.model(clf,
X_train=X, y_train=y,
feature_names=iris.feature_names,
target_name='iris',
class_names=iris.target_names)
v = viz_model.view() # render as SVG into internal object
v.show() # pop up window
v.save("/tmp/iris.svg") # optionally save as svg
In a notebook, you can render inline without calling show(). Just call view():
viz_model.view() # in notebook, displays inline
Installation
Install anaconda3 on your system, if not already done.
You might verify that you do not have conda-installed graphviz-related packages installed because dtreeviz needs the pip versions; you can remove them from conda space by doing:
conda uninstall python-graphviz
conda uninstall graphviz
To install (Python >=3.6 only), do this (from