dtreeviz  by parrt

Decision tree visualization and interpretation SDK

Created 7 years ago
3,117 stars

Top 15.2% on SourcePulse

GitHubView on GitHub
Project Summary

This Python library addresses the challenge of visualizing and interpreting decision trees, crucial components in popular machine learning models like Random Forests and gradient boosting machines. It targets machine learning engineers, researchers, and practitioners working with structured data, offering a significant aid for understanding model behavior and debugging. The primary benefit is enhanced model interpretability through detailed, educational visualizations.

How It Works

dtreeviz employs a visualization approach inspired by educational animations, utilizing an adaptor pattern (dtreeviz.model()) to extract necessary information from various decision tree implementations. This allows for a unified interface across supported libraries including scikit-learn, XGBoost, Spark MLlib, LightGBM, and TensorFlow. A key advantage is its ability to generate detailed visualizations of prediction paths, leaf node information, feature spaces, and classifier decision boundaries, offering deep insights into model logic.

Quick Start & Requirements

Installation is primarily via pip: pip install dtreeviz. Additional dependencies for specific libraries can be installed using extras, e.g., pip install dtreeviz[xgboost]. For AI chat features, install with pip install dtreeviz[ai] and set the OPENAI_API_KEY environment variable. Python version 3.6+ is required. A critical prerequisite is the Graphviz binary, with specific installation instructions provided for Mac (using Homebrew), Linux (Ubuntu: sudo apt install graphviz), and Windows (downloading MSI and updating PATH). Links to example notebooks for various supported libraries are available.

Highlighted Details

  • Supports visualization for scikit-learn, XGBoost, Spark MLlib, LightGBM, and TensorFlow decision trees.
  • The dtreeviz.decision_boundaries() function extends beyond tree models, working with any classifier supporting predict_proba().
  • Features AI-powered tree analysis, enabling ad-hoc querying of tree structure, nodes, and training data via a chat interface, with LLM-generated explanations integrated into visualizations.

Maintenance & Community

The project was initiated by Terence Parr, with significant contributions from Tudor Lapusan, Prince Grover, and Matthew Epland. Feedback and feature requests are welcomed via email or GitHub issues.

Licensing & Compatibility

The project is licensed under the permissive MIT license, allowing for broad compatibility with commercial and closed-source applications.

Limitations & Caveats

Currently, only SVG file output is supported. Jupyter Notebooks may exhibit rendering issues with SVGs due to a known bug, while Jupyter Lab displays them correctly. Platform-specific setup for the Graphviz binary can be complex. Internet Explorer is not recommended for viewing generated SVG files.

Health Check
Last Commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
3
Issues (30d)
2
Star History
10 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Wei-Lin Chiang Wei-Lin Chiang(Cofounder of LMArena), and
13 more.

awesome-tensor-compilers by merrymercy

0.1%
3k
Curated list of tensor compiler projects and papers
Created 5 years ago
Updated 1 year ago
Starred by Shengjia Zhao Shengjia Zhao(Chief Scientist at Meta Superintelligence Lab), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
14 more.

BIG-bench by google

0.1%
3k
Collaborative benchmark for probing and extrapolating LLM capabilities
Created 5 years ago
Updated 1 year ago
Starred by Lysandre Debut Lysandre Debut(Chief Open-Source Officer at Hugging Face), Shizhe Diao Shizhe Diao(Author of LMFlow; Research Scientist at NVIDIA), and
14 more.

simpletransformers by ThilinaRajapakse

0%
4k
Rapid NLP task implementation
Created 6 years ago
Updated 4 months ago
Starred by Aravind Srinivas Aravind Srinivas(Cofounder of Perplexity), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
16 more.

text-to-text-transfer-transformer by google-research

0.1%
6k
Unified text-to-text transformer for NLP research
Created 6 years ago
Updated 2 days ago
Starred by Vaibhav Nivargi Vaibhav Nivargi(Cofounder of Moveworks), Chuan Li Chuan Li(Chief Scientific Officer at Lambda), and
5 more.

awesome-mlops by visenger

0.1%
14k
Curated MLOps knowledge hub
Created 5 years ago
Updated 1 year ago
Feedback? Help us improve.