|
6 | 6 | [](https://pepy.tech/project/treeplot) |
7 | 7 | [](https://pepy.tech/project/treeplot/month) |
8 | 8 | [](https://www.buymeacoffee.com/erdogant) |
| 9 | +[](https://erdogant.github.io/treeplot/) |
9 | 10 | <!---[](https://erdogant.github.io/donate/?currency=USD&amount=5)--> |
10 | 11 |
|
11 | 12 | * ``treeplot`` is Python package to easily plot the tree derived from models such as decisiontrees, randomforest and xgboost. |
12 | 13 | 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. |
13 | 14 |
|
14 | | -# |
15 | | -**Star this repo if you like it! ⭐️** |
16 | | -# |
17 | | - |
18 | 15 | ### Functions in treeplot |
19 | 16 |
|
20 | 17 | 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 |
| 22 | + |
| 23 | +# |
| 24 | +**⭐️ Star this repo if you like it ⭐️** |
| 25 | +# |
25 | 26 |
|
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. |
| 27 | +#### Install treeplot from PyPI |
29 | 28 |
|
30 | | -#### Quick Start |
31 | | -``` |
| 29 | +```bash |
32 | 30 | pip install treeplot |
33 | 31 | ``` |
34 | 32 |
|
35 | | - |
36 | 33 | #### Import treeplot package |
37 | | -```python |
38 | | -import treeplot |
39 | | -``` |
40 | 34 |
|
41 | | -### Example RandomForest: |
42 | 35 | ```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 |
48 | 37 | ``` |
| 38 | +# |
49 | 39 |
|
50 | | -```python |
51 | | -# Make plot |
52 | | -ax = treeplot.plot(model) |
53 | | -# or directly |
54 | | -ax = treeplot.randomforest(model) |
55 | | -``` |
56 | | -<p align="center"> |
| 40 | + |
| 41 | +### [Documentation pages](https://erdogant.github.io/treeplot/) |
| 42 | + |
| 43 | +On the [documentation pages](https://erdogant.github.io/treeplot/) you can find detailed information about the working of the ``treeplot`` with examples. |
| 44 | + |
| 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#"> |
57 | 55 | <img src="https://github.com/erdogant/treeplot/blob/master/docs/figs/Figure_1.png" width="550" /> |
| 56 | + </a> |
58 | 57 | </p> |
59 | 58 |
|
60 | | -```python |
61 | | -# If more parameters needs to be specified, use the exact function: |
62 | | -ax = treeplot.randomforest(model, export='pdf') |
63 | | -``` |
| 59 | + |
| 60 | +# |
64 | 61 |
|
65 | 62 | #### Example XGboost: |
66 | 63 | ```python |
|
0 commit comments