0 votes

Is there a simple way to convert a DkuXGBRegressor instance to an XGBRegressor instance?

I'm trying to use the model in SHAP (https://shap.readthedocs.io/en/latest/#), but of course get the error: Model type not yet supported by TreeExplainer: <class 'dataiku.doctor.prediction.dku_xgboost.DkuXGBRegressor'>.

The XGBRegressor model is supported in SHAP, though.

reopened by

1 Answer

+1 vote
Best answer

Hello, this happens because the SHAP library tests against the name of the class (see here: https://github.com/slundberg/shap/blob/master/shap/explainers/tree.py#L510). 

To circumvent this, you can try the following:

from xgboost import XGBRegressor

# get clf as a DkuXGBRegressor
clf = ...

# cast cls as a XGBRegressor
clf.__class__ = XGBRegressor

# use SHAP with clf


selected by
I was hoping it was something that simple. That seems to have done the trick, thanks!
1,201 questions
1,229 answers
11,760 users

┬ęDataiku 2012-2018 - Privacy Policy