【问题标题】:Error in shap - AttributeError: module 'shap' has no attribute 'TreeExplainer'shap 中的错误 - AttributeError:模块“shap”没有属性“TreeExplainer”
【发布时间】:2021-01-09 14:45:38
【问题描述】:

当我使用时:

gb_explainer = shap.TreeExplainer

我收到此错误:

 AttributeError: module 'shap' has no attribute 'TreeExplainer'

完整代码:

    def create_shap_tree_explainer(self):

        self.gb_explainer = shap.TreeExplainer(self.gb_model)
        self.shap_values_X_test =   self.gb_explainer.shap_values(self.X_test)
        self.shap_values_X_train =  self.gb_explainer.shap_values(self.X_train)

梯度提升分类器模型为:

  gbc_model = Create_Gradient_Boosting_Classifier(X_train, y_train, ps)

【问题讨论】:

标签: python machine-learning shap


【解决方案1】:

您使用哪种 SHAP? 请检查一下。

print(shap.__version__)

另外,您是通过pipconda 安装SHAP 的吗?当你运行脚本时你的 python 访问哪里?我想,经过这样的检查,你会得到答案。

【讨论】:

    猜你喜欢
    • 2021-09-14
    • 2021-04-09
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 2021-06-23
    • 1970-01-01
    • 2022-01-03
    • 2019-07-04
    相关资源
    最近更新 更多