Skip to content

yupbank/tree_to_tensorflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Covert Tree Models to Tensorflow Tree.


CircleCI PyPI version codecov Code style: 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.

    
    from ttt import export_decision_tree

    clf = 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'

About

export tree family algo to tensorflow

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages