当前位置:   article > 正文

SHAP分析lightGBM_lightgbm shap

lightgbm shap

SHAP (SHapley Additive exPlanations) is a game theoretic approach to explain the output of any machine learning model. It connects optimal credit allocation with local explanations using the classic Shapley values from game theory and their related extensions (see papers for details and citations).

git 地址:https://github.com/slundberg/shap

代码:
valid_df = pd.read_pickle(f’…/input/riiid-cv2/cv1_valid.pickle’)
X_valid=valid_df[features]
X_valid=X_valid[0:1000]
model = lgb.Booster(model_file=f’…/input/riiid-lgbm-bagging-train2/model1.txt’)

model.params[“objective”] = “binary”
explainer = shap.TreeExplainer(model)
shap_values = explainer.shap_values(X_valid)
shap.summary_plot(shap_values, X_valid,max_display=50) #特征重要性可视化

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/285564
推荐阅读
相关标签
  

闽ICP备14008679号