'GradientExplainer not supporting XGBClassifier

I have trained the following XGBClassifier:

model = XGBClassifier( #XGBClassifier
    objective='binary:logistic',
    base_score=0.5, 
    booster='gbtree', 
    colsample_bylevel=1,
    colsample_bynode=1, 
    colsample_bytree=1,
    enable_categorical=False, 
    gamma=2, 
    gpu_id=-1,
    importance_type=None, 
    interaction_constraints='',
    learning_rate=0.1, 
    max_delta_step=0,
    max_depth=3,
    min_child_weight=7, 
    monotone_constraints='(1,1,1,1,1)',
    n_estimators=12, 
    n_jobs=1, 
    nthread=1, 
    num_parallel_tree=1,
    predictor='auto',
    random_state=0, 
    reg_alpha=0, 
    reg_lambda=1,
    scale_pos_weight=1, 
    silent=True, 
    subsample=0.8,
    tree_method='exact',
    validate_parameters=1, 
    pred_contribs=True,  
    verbose=True)
    
    
model.fit(X, Y)

Then I try to produce the SHAP value with this code:

explainer = shap.GradientExplainer(model,data = X)
shap_values = explainer.shap_values(X) 

But I get this error:

  File "C:\Users\glevorato\Anaconda3\lib\site-packages\shap\explainers\tf_utils.py", line 68, in _get_model_inputs
    assert False, str(type(model)) + " is not currently a supported model type!"

AssertionError: <class 'xgboost.sklearn.XGBClassifier'> is not currently a supported model type!

Does anybody know why? Is it because XGBClassifier is not supported? I need to use the GradientExplainer: what would be an alternative to XGBClassifier?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source