pymc-devs / pymc-bart

https://www.pymc.io/projects/bart
Other
86 stars 16 forks source link

Getting a frequentist model from BART model #147

Open ggmirandac opened 6 months ago

ggmirandac commented 6 months ago

Short Description

Hi, I have been wordering if there is a way to connect the bart regression model with some other tree based model, like XGboost or sklearn's trees. This in order to use the bart model to estimate some of the parameters of these models and then use the other tree models to generate SHAP values. This is based on the following blog in towardsdatascience.com: Bayesian inference.

This will generate a more thorough analysis of the black box model generated from the BART model.

Code Example or link

This can be seen in examples from : this blog post

And the shap value package is: shap

Relevant documentation or public examples

aloctavodia commented 6 months ago

Hi,

Thanks for sharing

What do you mean by "frequentist model"?

From a quick look at that notebook, what you need is to make predictions from a model and then pass those predictions to the shape package. That's something you can do with any PyMC model including BART models. You can compute predictions using pm.sample_posterior_predictive, no need to rewrite the model as in the notebook you shared. The author builds a SimpleModel class, which seems unnecessary to me.

I think we can add an example of this to the docs.

aloctavodia commented 6 months ago

Ohh, now I understand, the shap package is expecting an object with a prediction method. I guess that is what you mean by getting a "frequentist model". Still, the approach in that notebook is not very "pymc-onic". I guess the best approach will be to provide a utility function to simplify the user experience.

ggmirandac commented 6 months ago

Yeah,

Thanks for the consideration :D

Bests