Skip to content

Commit cbaa199

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 562d7e3 + 5322fc1 commit cbaa199

File tree

1 file changed

+47
-61
lines changed

1 file changed

+47
-61
lines changed

README.md

Lines changed: 47 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,97 +6,83 @@
66
[![Downloads](https://pepy.tech/badge/treeplot)](https://pepy.tech/project/treeplot)
77
[![Downloads](https://pepy.tech/badge/treeplot/month)](https://pepy.tech/project/treeplot/month)
88
[![BuyMeCoffee](https://img.shields.io/badge/buymea-coffee-yellow.svg)](https://www.buymeacoffee.com/erdogant)
9+
[![Sphinx](https://img.shields.io/badge/Sphinx-Docs-Green)](https://erdogant.github.io/treeplot/)
910
<!---[![Coffee](https://img.shields.io/badge/coffee-black-grey.svg)](https://erdogant.github.io/donate/?currency=USD&amount=5)-->
1011

1112
* ``treeplot`` is Python package to easily plot the tree derived from models such as decisiontrees, randomforest and xgboost.
1213
Developing explainable machine learning models is becoming more important in many domains. The most popular and classical explainable models are still tree based. Think of decision trees or random forest. The tree that is learned can be visualized and then explained. However, it can be a challange to simply plot the tree. Think of configuration issues with dot files, path locations to graphviz, differences across operating systems, differences across editors such as jupyter notebook, colab, spyder etc. This frustration led to this library, an easy way to plot the decision trees 🌲. It works for Random-forest, decission trees, xgboost and gradient boosting models. Under the hood it makes many checks, downloads graphviz, sets the path and then plots the tree.
1314

14-
#
15-
**Star this repo if you like it! ⭐️**
16-
#
17-
1815
### Functions in treeplot
1916

2017
Treeplot can plot the tree for Random-forest, decission trees, xgboost and gradient boosting models:
21-
* treeplot.plot() : Generic function to plot the tree of any of the four models with default settings
22-
* treeplot.randomforest() : Plot the randomforest model. Parameters can be specified.
23-
* treeplot.xgboost() : Plot the xgboost model. Parameters can be specified.
24-
* treeplot.import_example('iris') : Import example dataset
18+
* .plot : Generic function to plot the tree of any of the four models with default settings
19+
* .randomforest : Plot the randomforest model. Parameters can be specified.
20+
* .xgboost : Plot the xgboost model. Parameters can be specified.
21+
* .import_example('iris') : Import example dataset
2522

26-
### Installation
27-
* Install treeplot from PyPI (recommended). treeplot is compatible with Python 3.6+ and runs on Linux, MacOS X and Windows.
28-
* It is distributed under the MIT license.
23+
#
24+
**⭐️ Star this repo if you like it ⭐️**
25+
#
2926

30-
#### Quick Start
31-
```
27+
#### Install treeplot from PyPI
28+
29+
```bash
3230
pip install treeplot
3331
```
3432

35-
3633
#### Import treeplot package
37-
```python
38-
import treeplot
39-
```
4034

41-
### Example RandomForest:
4235
```python
43-
# Load example dataset
44-
X,y = treeplot.import_example()
45-
# Learn model
46-
from sklearn.ensemble import RandomForestClassifier
47-
model = RandomForestClassifier(n_estimators=100, max_depth=2, random_state=0).fit(X, y)
36+
import treeplot as tree
4837
```
38+
#
4939

50-
```python
51-
# Make plot
52-
ax = treeplot.plot(model)
53-
# or directly
54-
ax = treeplot.randomforest(model)
55-
```
56-
<p align="center">
57-
<img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/Figure_1.png" width="550" />
58-
</p>
5940

60-
```python
61-
# If more parameters needs to be specified, use the exact function:
62-
ax = treeplot.randomforest(model, export='pdf')
63-
```
41+
### [Documentation pages](https://erdogant.github.io/treeplot/)
6442

65-
#### Example XGboost:
66-
```python
67-
# Load example dataset
68-
X,y = treeplot.import_example()
69-
# Learn model
70-
from xgboost import XGBClassifier
71-
model = XGBClassifier(n_estimators=100, max_depth=2, random_state=0).fit(X, y)
72-
```
43+
On the [documentation pages](https://erdogant.github.io/treeplot/) you can find detailed information about the working of the ``treeplot`` with examples.
7344

74-
```python
75-
# Make plot
76-
ax = treeplot.plot(model)
77-
# or directly
78-
ax = treeplot.xgboost(model)
79-
```
80-
<p align="center">
81-
<img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/Figure2_xgboost_hor.png" width="550" />
82-
<img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/Figure2_featimportance.png" width="350" />
45+
<hr>
46+
47+
### Examples
48+
49+
#
50+
51+
* [Example: RandomForest](https://erdogant.github.io/treeplot/pages/html/Examples.html#)
52+
53+
<p align="left">
54+
<a href="https://erdogant.github.io/treeplot/pages/html/Examples.html#">
55+
<img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/fig_breast_randomforest.png" width="600" />
56+
</a>
8357
</p>
8458

85-
```python
86-
# If more parameters needs to be specified, use the exact function:
87-
ax = treeplot.xgboost(model, plottype='vertical')
88-
```
89-
<p align="center">
90-
<img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/Figure2_xgboost_ver.png" width="550" />
59+
60+
#
61+
62+
* [Example: XGboot](https://erdogant.github.io/treeplot/pages/html/Examples.html#xgboost)
63+
64+
<p align="left">
65+
<a href="https://erdogant.github.io/treeplot/pages/html/Examples.html#xgboost">
66+
<img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/fig_breast_xgboot_tree.png" width="600" />
67+
<br>
68+
<img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/fig_breast_xgboot_weights.png" width="600" />
69+
</a>
9170
</p>
9271

9372

73+
#
74+
* [Example: gradientboostingclassifier](https://erdogant.github.io/treeplot/pages/html/Examples.html#gradientboostingclassifier)
75+
#
76+
* [Example: lightbm](https://erdogant.github.io/treeplot/pages/html/Examples.html#lightbm)
77+
#
78+
* [Example: Explore other trees such as second best tree etc](https://erdogant.github.io/treeplot/pages/html/Examples.html#plot-second-best-tree-and-other-trees)
79+
80+
<hr>
81+
9482
#### Maintainers
9583
* Erdogan Taskesen, github: [erdogant](https://github.com/erdogant)
9684

9785
#### Contribute
9886
* Contributions are welcome.
9987
* If you wish to buy me a <a href="https://www.buymeacoffee.com/erdogant">Coffee</a> for this work, it is very appreciated :)
10088

101-
#### Licence
102-
See [LICENSE](LICENSE) for details.

0 commit comments

Comments
 (0)