使用 fasttreeshap 计算 XGB 模型的 SHAP 值

Calculating SHAP values of an XGB model using fasttreeshap

提问人:arilwan 提问时间:11/8/2023 最后编辑:arilwan 更新时间:11/8/2023 访问量:19

问:

我的安装是这样的:XGBoost

model = XGBClassifier(n_estimators=1000)
model.fit(X_train, Y_train)

因此,我想使用该算法的 FastTreeSHAP 实现来加快计算速度,因为数据集足够大。TreeSHAP

import fasttreeshap

explainer = fasttreeshap.TreeExplainer(model, algorithm='auto' ,n_jobs=-1)
shap_values = explainer(X_test).values

但是,当我遇到以下错误时:

Exception: Additivity check failed in TreeExplainer! Please ensure the 
data matrix you passed to the explainer is the same shape that the model was
 trained on.

我不明白这个错误意味着什么,但可以肯定的是,它不应该意味着(当然,我们经常分成X_train.shape = X_test.shapetrain:test70:30)

# Version info:
>>> import fasttreeshap, xgboost
>>> print(fasttreeshap.__version__)
0.1.6
>>> print(xgboost.__version__)
1.7.4
>>> 
蟒蛇 xgboost shap fasttreeshap

评论


答: 暂无答案