Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
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.
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
...
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
...