【问题标题】:Is there a way to print one XGBoostRegressor tree in python?有没有办法在 python 中打印一个 XGBoostRegressor 树?
【发布时间】:2019-07-23 14:16:50
【问题描述】:

我已经构建了一个 XGBoostRegressor 模型,现在我想尝试绘制其中一棵树。我知道常规的 xgb 分类器具有函数 plot_tree 但不幸的是 XGBoostRegressor 没有。有没有其他方法可以绘制树?我还尝试从 xgboost 导入 plot_tree 并使用返回的 plot_tree(xgb)

ValueError('Unable to parse node: 44['product_family'])

如果有其他方法可以做到这一点,有什么想法吗?

【问题讨论】:

    标签: python xgboost


    【解决方案1】:

    我发现了错误,我的一些功能名称中有一些空格。我添加了以下行

        df.columns = df.columns.str.replace(" ", "_")
    

    现在它可以使用 plot_tree(xgb)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-02-25
      • 2018-05-16
      • 1970-01-01
      • 1970-01-01
      • 2021-12-24
      • 2021-07-09
      • 2019-07-26
      相关资源
      最近更新 更多