获取用于提前停止的 GBM 的树数
Get the number of trees used for a GBM with early stopping
我使用提前停止和设置 ntrees=10000
在 h2o 中训练了一个 GBM。我想检索模型中实际存在的树木数量。但是,如果我调用 model.params['ntrees']
(其中 model
是来自网格搜索的最佳模型),我会得到
{'default': 50, 'actual': 10000}
其中 10000
是我在训练期间设置的参数,而不是最终出现在模型中的实际树木数量。
如果我调用 model.score_history()
,那么我可以看到在 280
棵树上开始提前停止。但肯定有比这个 hack 更直接的方法来找出模型中树木的实际数量:
best_model.score_history()['number_of_trees'].max()
目前没有一种干净的方法可以做到这一点。另一种不需要计算最大值但仍然笨拙的方法是 model.summary()['number_of_trees'][0]
如果你想要数字,如果你想要列表中的数字 model.summary()['number_of_trees']
。或者只是 model.summary()
如果您只想查看数字。
我使用提前停止和设置 ntrees=10000
在 h2o 中训练了一个 GBM。我想检索模型中实际存在的树木数量。但是,如果我调用 model.params['ntrees']
(其中 model
是来自网格搜索的最佳模型),我会得到
{'default': 50, 'actual': 10000}
其中 10000
是我在训练期间设置的参数,而不是最终出现在模型中的实际树木数量。
如果我调用 model.score_history()
,那么我可以看到在 280
棵树上开始提前停止。但肯定有比这个 hack 更直接的方法来找出模型中树木的实际数量:
best_model.score_history()['number_of_trees'].max()
目前没有一种干净的方法可以做到这一点。另一种不需要计算最大值但仍然笨拙的方法是 model.summary()['number_of_trees'][0]
如果你想要数字,如果你想要列表中的数字 model.summary()['number_of_trees']
。或者只是 model.summary()
如果您只想查看数字。