【问题标题】:Plotly Dash: How to integrate SHAP valuesPlotly Dash:如何整合 SHAP 值
【发布时间】:2021-04-12 07:38:03
【问题描述】:

我正在尝试使用 Plotly Dash 与来自 shap 值的信息制作模型解释器页面。但我不知道如何从Shap获取输出

代码如下:

#load data & model
cat_model = pickle.load(open('cat-model.saved', 'rb'))

PREPROCESS_DIR = "preprocess-data"
X_test = pickle.load(open(PREPROCESS_DIR+'/X_test_60k.saved', 'rb'))
y_test = pickle.load(open(PREPROCESS_DIR+'/y_test_60k.saved', 'rb'))

explainer = shap.TreeExplainer(cat_model)
shap_values = explainer.shap_values(X_test)


# visualize the first prediction's explanation

shap_html = shap.force_plot(explainer.expected_value, shap_values[:1000,:], X_test.iloc[:1000,:])
    
    
# TODO: Build and run dash app
app = dash.Dash(__name__)
app.config.suppress_callback_exceptions = True

app.layout = html.Div([
    html.H1('Model Explainer', style={'textAlign':'center','color':'#503D36','fontSize':'30px'}),

    html.Div([shap_html], id='output-shap')
])


if __name__ == '__main__':
    app.run_server(debug=True)

【问题讨论】:

    标签: python plotly plotly-dash plotly-python shap


    【解决方案1】:

    使用explainerdashboard 库。它允许您调查 SHAP 值、排列重要性、交互效应、部分依赖图、各种性能图,甚至是随机森林中的单个决策树。

    https://explainerdashboard.readthedocs.io/en/latest/

    【讨论】:

      猜你喜欢
      • 2019-12-17
      • 1970-01-01
      • 2019-06-25
      • 1970-01-01
      • 2023-03-05
      • 2021-07-11
      • 1970-01-01
      • 2021-02-25
      • 2020-11-25
      相关资源
      最近更新 更多