我使用Python中的Shap库来解释我使用Catboost实现的模型。当尝试使用多个绘图时,我使用以下命令:
shap.summary_plot(shap_values, X_train)
shap.force_plot(explainer.expected_value, shap_values, X_train)
shap.dependence_plot("some feature", shap_values, X_train)每种方法的输出都给出了x轴上的Shap值,但是我无法解释它,并且认为使用概率更容易。我怎么能做到这一点呢?
我在Catboost上读到了它不能使用:explainer = shap.TreeExplainer(model,data = X,model_output='probability')
因此,我不知道该怎么做。
发布于 2021-11-22 14:28:31
可以考虑的一件事是在force_plot上使用日志链接,这在the shap vignette中显示,例如:
import shap
import numpy as np
from sklearn.model_selection import train_test_split
shap.initjs()
X,y = shap.datasets.iris()
y = np.where(y==1,1,0)
X_train,X_test,Y_train,Y_test = train_test_split(X,y, test_size=0.2, random_state=0)
from catboost import CatBoostClassifier, Pool
model = CatBoostClassifier(verbose=False)
model.fit(X_train,Y_train)
explainer = shap.KernelExplainer(model.predict_proba, X_train, link="logit")
shap_values = explainer.shap_values(X_test, nsamples=10)
shap.force_plot(explainer.expected_value[2], shap_values[2], X_test, link="logit")

由此,您可以跨越所有样本,了解每个特征对最终概率的贡献
https://stackoverflow.com/questions/70062847
复制相似问题