Python package treeplot vizualizes a tree based on a randomforest or xgboost model.
Project description
treeplot
- treeplot is Python package to easily plot the tree derived from models such as decisiontrees, randomforest and xgboost.
Contents
Installation
- Install treeplot from PyPI (recommended). treeplot is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows.
- It is distributed under the MIT license.
Quick Start
pip install treeplot
- Alternatively, install treeplot from the GitHub source:
git clone https://github.com/erdogant/treeplot.git
cd treeplot
python setup.py install
Import treeplot package
import treeplot
Example RandomForest:
# Load example dataset
X,y = treeplot.import_example()
# Learn model
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier(n_estimators=100, max_depth=2, random_state=0).fit(X, y)
# Make plot
ax = treeplot.plot(model)
# If you have more parameters to specify:
ax = treeplot.randomforest(model, export='pdf')
Example XGboost:
# Load example dataset
X,y = treeplot.import_example()
# Learn model
from xgboost import XGBClassifier
model = XGBClassifier(n_estimators=100, max_depth=2, random_state=0).fit(X, y)
# Make plot
ax = treeplot.plot(model)
# If you have more parameters to specify:
ax = treeplot.xgboost(model, plottype='vertical')
Maintainers
- Erdogan Taskesen, github: erdogant
Contribute
- Contributions are welcome.
Licence
See LICENSE for details.
Donation
- This work is created and maintained in my free time. Contributions of any kind are very appreciated. Sponsering is also possible.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
treeplot-0.1.7.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file treeplot-0.1.7.tar.gz
.
File metadata
- Download URL: treeplot-0.1.7.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0.post20200127 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 356b98e2add24413cbf74d18884ebc5e98d02f6a75386d5314126a398b41179e |
|
MD5 | bc0accfd59d0fb02c85deef002d3fe5a |
|
BLAKE2b-256 | ea74ad8560231ba144b5e0cdd5d7c86af8d805475d5ae310a7e849b037ef0feb |
File details
Details for the file treeplot-0.1.7-py3-none-any.whl
.
File metadata
- Download URL: treeplot-0.1.7-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0.post20200127 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.6.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20053438b79c82f72c821b02ad24a640c3ea7a1b346e0b74879df5ef71f56412 |
|
MD5 | b7e89756ee765016a48bade26ca53324 |
|
BLAKE2b-256 | eb092c717bd781e839f9f375b405928b551476474f318c05f284ac2e78eb50b6 |