interpret icon indicating copy to clipboard operation
interpret copied to clipboard

Create submodels of an ExplainableBoostingRegressor(outer_bags=14)?

Open gisandnes opened this issue 2 years ago • 1 comments

As I understand it an ExplainableBoostingRegressor(outer_bags=14) is an ensemble of 14 different ExplainableBoostingRegressors(outer_bags=1). All parameters except outer_bags are the same between the models. For cross-validation I would like to extract the 14 submodels, predict on the "unseen" validation data for each and to calculate a metric on each validation data set. Then take an average of metrics values.

I fit an ExplainableBoostingRegressor(outer_bags=14), using a bags matrix. The bags matrix has shape (14, #samples). It contains only +1 and -1 values. My objective is Tweedie deviance.

To create the submodels:

a. Should I start with training 14 different ExplainableBoostingRegressor(outer_bags=1), where the first uses bags[0] (shape (1, #samples)) , the second bags[1] (shape (1, #samples)) , ... ? b. How can I combine the predictions from the 14 ExplainableBoostingRegressor(outer_bags=1) models, to get the same predictions as from the ExplainableBoostingRegressor(outer_bags=14)? c. How can I make 14 copies of the trained ExplainableBoostingRegressor(outer_bags=14) and overwrite some of its variables, to get trained ExplainableBoostingRegressors(outer_bags=1) equal to those in a. ?

Correct me if I have misunderstood. Is this possible?

gisandnes avatar Jun 18 '24 14:06 gisandnes

Hi @gisandnes -- You can do either of these. If you want to train 14 separate ExplainableBoostingRegressor models with 1 outer bag each, you can combine them afterwards using the merge_ebms function. One complication with this route is that each of the separate EBMs will probably select a different set of interactions since there are slight variations in the interaction metrics across bags. You can resolve this by training EBMs without interactions, then using the measure_interactions function to choose a common set of interactions, then train new EBMs by specifying the interactions explicitly. There is an example in our documentation that shows how to handle custom interactions: https://interpret.ml/docs/python/examples/custom-interactions.html

The other way, which I would recommend instead, is a bit hacker but easier. We store each of the bagged models inside the ExplainableBoostingRegressor object. You can force the EBM to behave as if it were one of the bagged models with:

# make the EBM behave as one of the bagged models
ebm.term_scores_ = ebm.bagged_scores_[3]
ebm.intercept_ = ebm.bagged_intercept_[3]
ebm.standard_deviations_ = None  # remove the error bars, which no longer apply with 1 bag

And it should behave identically to that individual bagged model for both prediction and feature/term importances.

I guess this functionality should be added to our API since it seems like it would be a common scenario.

paulbkoch avatar Jun 18 '24 23:06 paulbkoch