我用h2o建立了一个随机森林模型。我想用h2otree绘制它。我收到TypeError:“ NoneType”对象不可迭代
我可以复制该错误。类H2OTree调用函数__decode_categoricals(model, response['levels'])
,该函数在类型为None的响应级别上进行迭代。
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')
答案 0 :(得分:0)
如果您想可视化H2O树,则可以使用Mojo Visualizer(文档here)或查看有关此的先前问题/帖子:
Visualizing H2O GBM and Random Forest MOJO Models Trees in Python