【问题标题】:Type error when visualising h2o random-forest model tree可视化 h2o 随机森林模型树时的类型错误
【发布时间】:2019-11-22 01:08:30
【问题描述】:

我已经用 h2o 建立了一个随机森林模型。我正在尝试用 h2otree 绘制它。我收到一个 TypeError: 'NoneType' object is not iterable

我可以复制错误。 H2OTree 类调用函数 __decode_categoricals(model, response['levels']),它迭代无类型的响应级别。

from h2o.tree import H2OTree
first_tree = H2OTree(model = rf_model, tree_number = 0, tree_class = target_class_category)
#error replication
params = {"model": model.model_id,
                  "tree_number": 0,
                  "tree_class": target_class_category}


response = h2o.api(endpoint="GET /3/Tree", data=params)
for lvl_index in response['levels']:

    if len(lvl_index) >0: #error, 'NoneType' has no len()
        print('yes')

【问题讨论】:

    标签: python random-forest h2o


    【解决方案1】:

    如果您想可视化 H2O 树,您可以使用 Mojo Visualizer(文档 here)或查看之前的问题/帖子:

    How to visualize H2O Tree?

    Visualizing H2O GBM and Random Forest MOJO Models Trees in Python

    【讨论】:

      猜你喜欢
      • 2018-09-26
      • 2019-05-08
      • 2016-01-24
      • 2019-08-11
      • 2017-10-20
      • 1970-01-01
      • 1970-01-01
      • 2016-11-30
      • 2019-07-10
      相关资源
      最近更新 更多