简体   繁体   English

在处理上述异常时,使用SHAP解释keras神经网络model时又出现异常

[英]During handling of the above exception, another exception occurred when using SHAP to interpret keras neural network model

The x_train looks like this (22 features): x_train看起来像这样(22 个特征):


total_amount    reward  difficulty  duration    discount    bogo    mobile  social  web income  ... male    other_gender    age_under25 age_25_to_35    age_35_to_45    age_45_to_55    age_55_to_65    age_65_to_75    age_75_to_85    age_85_to_105
0   0.006311    0.2 0.50    1.000000    1.0 0.0 1.0 1.0 1.0 0.355556    ... 1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0
1   0.015595    0.2 0.50    1.000000    1.0 0.0 1.0 1.0 1.0 0.977778    ... 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0

The label is 0 and 1 , it's a binary classification problem, here's the code for building the model, and I was following this page to implement SHAP: label 是01 ,这是一个二进制分类问题,这是构建 model 的代码,我正在关注这个页面来实现 SHAP:


#use SHAG
deep_explainer = shap.DeepExplainer(nn_model_2, x_train[:100])

# explain the first 10 predictions
# explaining each prediction requires 2 * background dataset size runs
shap_values = deep_explainer.shap_values(x_train)

This gave me error:这给了我错误:

KeyError: 0

During handling of the above exception, another exception occurred

I have no idea what this message is complaining, I tried to use SHAP with a XGBoost and Logistic Regression model and they both work fine, I'm new to keras and SHAP, can someone have a look for me and how I can solved it?我不知道这条消息在抱怨什么,我尝试将 SHAP 与 XGBoost 和逻辑回归 model 一起使用,它们都工作正常,我是 keras 和 SHAP 的新手,有人可以看看我以及我如何解决它? Many thanks.非常感谢。

I think SHAP (whatever it is) is expecting a Numpy array and so indexing x_train like a Numpy array, it yields an error.我认为SHAP (无论它是什么)期待一个 Numpy 数组,因此像 Numpy 数组一样索引x_train ,它会产生错误。 Try:尝试:

shap_values = deep_explainer.shap_values(x_train.values)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在处理上述异常的过程中,又发生了一个异常 - During handling of the above exception, another exception occurred 在处理上述异常期间,发生了另一个异常:Python程序 - During handling of the above exception, another exception occurred: Python program KeyError: 1 在处理上述异常的过程中,又发生了一个异常: - KeyError: 1 During handling of the above exception, another exception occurred: 在处理上述异常的过程中,又发生了一个异常:& google sheet not found - During handling of the above exception, another exception occurred: & google sheets not found “在处理上述异常过程中,发生了另一个异常”for循环中的第一个输入 - “ during the handling of above exception, another exception occurred ” for the first input in the for loop 如何解决“在处理上述异常期间,发生了另一个异常:” - How to fix "During handling of the above exception, another exception occurred: " Flask-restful - 在处理上述异常的过程中,发生了另一个异常 - Flask-restful - During handling of the above exception, another exception occurred 关键错误:1 在处理上述异常的过程中,发生了另一个异常 - Key Error: 1 During handling of the above exception, another exception occurred KeyError:在处理上述异常的过程中,发生了另一个异常 - KeyError: During handling of the above exception, another exception occurred 在处理上述异常的过程中,发生了另一个异常:'Date' - During handling of the above exception, another exception occurred: 'Date'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM