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.5.tar.gz
(28.4 MB
view details)
Built Distribution
treeplot-0.1.5-py3-none-any.whl
(28.4 MB
view details)
File details
Details for the file treeplot-0.1.5.tar.gz
.
File metadata
- Download URL: treeplot-0.1.5.tar.gz
- Upload date:
- Size: 28.4 MB
- 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 |
11dde62d5b6ebbd819f6adeabccc4b465c50434cf6382f0ab5350ae5b65d5bee
|
|
MD5 |
1658769a422b02683b5e69beaa527a69
|
|
BLAKE2b-256 |
909db40f2e582d71ba39875adee9e90bb330c5d796c03ae73b6f1b4234d9f757
|
File details
Details for the file treeplot-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: treeplot-0.1.5-py3-none-any.whl
- Upload date:
- Size: 28.4 MB
- 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 |
54b7869e3fe0469ed7f72a8caff6179c0dfbb6d1e090d907f21f4126c1489dab
|
|
MD5 |
36ffdd93b52e1a656e33492730a01fd4
|
|
BLAKE2b-256 |
3e90e4f663c83e24327c504bbf8f3e386e5ee25e97dd0ee4772a1f42333ebebc
|