https://github.com/yupbank/tree_to_tensorflow
export tree family algo to tensorflow
https://github.com/yupbank/tree_to_tensorflow
Last synced: 4 months ago
JSON representation
export tree family algo to tensorflow
- Host: GitHub
- URL: https://github.com/yupbank/tree_to_tensorflow
- Owner: yupbank
- Created: 2018-01-22T22:22:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-18T20:01:35.000Z (over 5 years ago)
- Last Synced: 2025-01-31T02:21:59.840Z (4 months ago)
- Language: Python
- Size: 67.4 KB
- Stars: 9
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Covert Tree Models to Tensorflow Tree.
---
[](https://circleci.com/gh/yupbank/tree_to_tensorflow/tree/master)
[](https://badge.fury.io/py/TFTree)
[](https://codecov.io/gh/yupbank/tree_to_tensorflow)
[](https://github.com/psf/black)# The Goal is to have one unified tree runtime
* Convert a xgboost Tree/Forest into Tensorflow Graph.
* Convert a sciki-learn Tree/Forest into Tensorflow Graph.
### Example
Convert fitted
- `sklearn.DecisionTreeClassifier`
- `sklearn.DecisionTreeRegressor`
- `sklearn.RandomForestRegressor`
- `sklearn.RandomForestClassifier`
- `xgboost.XGBClassifier`
- `xgboost.XGBRegressor`to `tensorflow.saved_model`
All you need to do is pass your desired `model_dir`, `'./tmp'` in this example and a fitted classifier.
```python
from ttt import export_decision_treeclf = sklearn.ensemble.RandomForestClassifier()
clf.fit(X, y)
features = {'features': tf.placeholder(tf.float64, [None, X.shape[1]])}
export_decision_tree(clf, features, 'sklearn_saved_model')xgb_model = xgboost.XGBClassifier().fit(X, y)
export_decision_tree(xgb_model, features, 'xgb_saved_model')
```And then you can server this model with tf/serving using 'saved_model'