【发布时间】:2019-08-23 15:43:06
【问题描述】:
我正在使用 DeepExplainer 来获取深度学习模型的 shap 值。通过遵循一些教程,我可以获得一些结果,即哪些变量从基值推动模型预测,基值是训练集中的平均模型输出。
我有大约 5,000 个观察值和 70 个特征。 DeepExplainer 的表现中规中矩。我的代码是:
model0 = load_model(model_p+'health0.h5')
background = healthScaler.transform(train[healthFeatures])
e = shap.DeepExplainer(model0, background)
shap_values = e.shap_values(healthScaler.transform(test[healthFeatures]))
test2 = test[healthFeatures].copy()
test2[healthFeatures] = healthScaler.transform(test[healthFeatures])
shap.force_plot(e.expected_value[0], shap_values[0][947,:], test2.iloc[947,:])
这里的基值为0.012(也可以通过e.expected_value[0]看到),非常接近输出值0.01。
此时我有一些问题:
1) 输出值与通过model0.predict(test[healthFeatures])[947] = -0.103得到的预测值不完全相同,我应该如何评估输出值?
2) 可以看出,我使用整个训练集作为背景来近似 SHAP 值的条件期望。使用训练集和整个集的随机样本有什么区别?是否只与性能问题有关?
提前非常感谢!
【问题讨论】:
-
你知道 DeepExplainer 是否适合 MLPClassifier 还是我应该使用 KernelExplainer?第二个选项似乎消耗了 google colab 上所有可用的 RAM
标签: tensorflow keras neural-network deep-learning shap