crflynn / skgrf

scikit-learn compatible Python bindings for grf (generalized random forests) C++ random forest library
https://skgrf.readthedocs.io/en/stable/
GNU General Public License v3.0
30 stars 6 forks source link

SHAP on Forest Causal Regressor #92

Open gcasamat opened 1 year ago

gcasamat commented 1 year ago

Hi, thanks for this very useful package. I would like to compute SHAP values of a causal forest model.
I ran a code similar to the one given in https://skgrf.readthedocs.io/en/latest/tree/tree_interface.html#shap , except that my model is :

cf = GRFForestCausalRegressor(enable_tree_details = True)
cf.fit(X, Y, W, Y_hat_nomissing, W_hat_nomissing)

This works fine. However, SHAP considers as predictions of my model the predicted values of Y, whereas I would like to consider as predictions the conditional effects of my treatment variable W on the target Y, which are typically the values given by cf.predict(). I wonder if there exists a way of achieving my desired outcome?