TypeError:__init __()缺少1所需的位置参数:' data'
在Python中,我已经阅读了名为flaml_lgbm.pmml
的LightGBM PMML文件,就像:
from pypmml import Model
model = Model.fromFile('flaml_lgbm.pmml')
然后我尝试使用这些代码行生成Shap Graph:
shap_values = shap.KernelExplainer(model).shap_values(X)
shap.summary_plot(shap_values, X, plot_type="bar")
# positive and negative relationships of the predictors with the target variable
shap.summary_plot(shap_values, X)
但是我遇到了此错误:
shap_values = shap.KernelExplainer(model).shap_values(X)
TypeError: __init__() missing 1 required positional argument: 'data'
什么问题 :使用代码,我该如何修复?
In Python, I have read in a lightGBM pmml file named flaml_lgbm.pmml
, like so:
from pypmml import Model
model = Model.fromFile('flaml_lgbm.pmml')
Then I have tried to generate the SHAP graph with these lines of code:
shap_values = shap.KernelExplainer(model).shap_values(X)
shap.summary_plot(shap_values, X, plot_type="bar")
# positive and negative relationships of the predictors with the target variable
shap.summary_plot(shap_values, X)
But I get this error:
shap_values = shap.KernelExplainer(model).shap_values(X)
TypeError: __init__() missing 1 required positional argument: 'data'
What is wrong with the code, and how can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要在 shap.kernelexplainer()中也包含数据,请尝试以下操作:
You simply need to include data also in shap.KernelExplainer(), try this: