TypeError:__init __()缺少1所需的位置参数:' data'

发布于 2025-02-04 08:30:53 字数 647 浏览 3 评论 0原文

在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽清梦 2025-02-11 08:30:53

您只需要在 shap.kernelexplainer()中也包含数据,请尝试以下操作:

shap_values = shap.KernelExplainer(model, X).shap_values(X)

You simply need to include data also in shap.KernelExplainer(), try this:

shap_values = shap.KernelExplainer(model, X).shap_values(X)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文