水中总叶数

total leaf count in h2o

我使用 r 在 h2o 中创建了一个随机森林。它有树和叶子。

我想知道有多少叶子。我喜欢将我的总行数与叶子进行比较。

我有 200 棵树,8 层深,每个终端叶子需要 5 行。我是否遍历了大部分数据?我有 20k 行。

有没有一种干净的方法来计算 h2o randomForest 中的叶子数量?

你会很高兴知道 H2O 存储了这些信息!例如。 (这是 Iris 数据集)

m <- h2o.randomForest(1:4, 5, data)

打印时 m 我看到:

number_of_trees model_size_in_bytes min_depth max_depth mean_depth min_leaves  max_leaves mean_leaves
            150               20217         1         9    3.72667          21         15     6.17333

所以有 926 片树叶 (6.17333 * 150)。

使用代码获取:

ms = m@model$model_summary
ms$number_of_trees * ms$mean_leaves