🐳 模型可解释性 SHAP 🐳
1、SHAP 简介
SHAP 全称 SHapley Additive exPlanation,发表于 NIPS 2017 。
SHAP 属于模型事后解释的方法。核心思想是计算特征对模型输出的边际贡献,再从全局和局部两个层面对黑盒模型进行解释。
SHAP 示意图如下所示。
2、SHAP 环境配置
本地环境为 WIndows 10 + python 3.6.2。根据 SHAP source code 直接 pip install shap
即可。
3、SHAP 测试
以 SHAP source code 中的 Boston 房价为例,SHAP 可以提供:
- 任一样本的各个特征对其类别 (分类概率值) 的贡献大小。
- 单个/多个特征的值的大小对模型预测结果的影响。
- 参考 SHAP 的理解与应用 可以使 SHAP 适用于 one-hot 编码。
4、SHAP 相关参考
一些参考如下:
- SHAP in kaggle 。
- Github,SHAP source code 。
- 中文博客,SHAP 模型:可解释机器学习模型 ,SHAP 的理解与应用 ,利用 SHAP 解释 Xgboost 模型 。
- 图书,Interpretable Machine Learning ,可解释机器学习 (译) 。
- Paper,Lundberg, S. M., & Lee, S. I. (2017, December). A unified approach to interpreting model predictions. In Proceedings of the 31st international conference on neural information processing systems (pp. 4768-4777).