Solved – How to get coefficients of gradient boosting models

boostingpythonr

I tried gradient boosting models using both gbm in R and sklearn in Python. However, neither of them can provide the coefficients of the model. For gbm in R, it seems one can get the tree structure, but I can't find a way to get the coefficients. For sklearn in Python, I can't even see the tree structure, not to mention the coefficients. Can anyone give me some help?

After searching online for couple of hours, I still can't find the answer. I can find similar questions since 2009, but no answers. Like the followings:

This make me wonder if R and Python are mainly used by academic people, and thus majority of the users don't care about how to use them in industry. For example, if you want to implement the results in some real-time platform which doesn't run Python, what would you do?

Best Answer

I use R "in industry". GBM's and other tree-based methods don't have "coefficients" so it's pointless to try to extract them.

What you CAN do is encode each tree as a SQL query. It take a little effort, but once you can do it for a single tree, you can loop over all the trees in a model, generate ~500 SQL queries, and use them to score your model on a database of your choosing.