赞
踩
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) #特征重要性可视化
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。