konstantint / SKompiler

A tool for compiling trained SKLearn models into other representations (such as SQL, Sympy or Excel formulas)
MIT License
171 stars 10 forks source link

Support GradientBoostingClassifier #3

Closed GrootOnTheRocket closed 5 years ago

GrootOnTheRocket commented 5 years ago

Hello, Now I'm struggling to export my GradientBoostingClassifier’s “predict_proba” method into c code. And in many examples, I saw it works for GradientBoostingRegressor model. But it seems not to work with GradientBoostingClassifier model. Instead using GradientBoostingRegressor model, is there another way for GradientBoostingClassifier model?

I got an error message like this, "ValueError: Method predict_proba is not supported (or not implemented yet) for GradientBoostingClassifier".

In addition, I also tried using “decision_function” method. But it didn’t work still with “AttributeError: ‘LogOddsEstimator’ object has no attribute ‘priors’” message.

GrootOnTheRocket commented 5 years ago

For a temporal method, I fixed a few codes of "gradient_boosting.py" in skompiler library. At first, I replaced "tree_exprs" definition in gradient_boosting_classifier function to "tree_exprs" definition in gradient_boosting_regressor function. And in the "return" code, fixed "priors" to "prior".

With this change, I got "GBM.decision_function" and converted to probabilities. and all result was the same.