使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
袋外评估
随机森林不需要验证数据集。大多数随机森林都使用一种称为袋外评估 (OOB evaluation) 的技术来评估模型的质量。OOB 评估会将训练集视为交叉验证的测试集。
如前所述,随机森林中的每个决策树通常都基于约 67% 的训练示例进行训练。因此,每个决策树都不会看到大约 33% 的训练示例。OOB 评估的核心思想如下:
- 在训练集中评估随机森林。
- 对于每个示例,仅使用在训练期间未看到该示例的决策树。
下表展示了使用 6 个示例训练的 3 个决策树的随机森林的 OOB 评估结果。(是的,这与“打包”部分中的表格相同)。下表显示了 OOB 评估期间哪个决策树与哪个示例搭配使用。
表 7. OOB 评估 - 这些数字表示在给定示例的训练期间使用给定训练示例的次数
|
训练示例 |
OOB 评估示例 |
|
#1 | #2 | #3 | #4 | #5 | #6 |
|
原始数据集 |
1 | 1 | 1 | 1 | 1 | 1 |
决策树 1 |
1 | 1 | 0 | 2 | 1 | 1 |
#3 |
决策树 2 |
3 | 0 | 1 | 0 | 2 | 0 |
#2、#4 和 #6 |
决策树 3 |
0 | 1 | 3 | 1 | 0 | 1 |
#1 和 #5 |
在表 7 中显示的示例中,系统将使用决策树 #3 计算训练示例 1 的 OOB 预测结果(因为决策树 #1 和 #2 使用了此示例进行训练)。在实践中,对于大小适当的数据集和几个决策树,所有示例都有 OOB 预测。
在 YDF 中,如果模型是使用 compute_oob_performances=True
训练的,则训练日志中会提供 OOB 评估。
OOB 评估对于计算随机森林模型的排列变量重要性也非常有效。回想一下变量重要性部分,排列变量重要性是通过衡量此变量随机排列后模型质量下降程度来衡量变量的重要性的。随机森林“OOB 排列变量重要性”是使用 OOB 评估计算的排列变量重要性。
在 YDF 中,如果模型是使用 compute_oob_variable_importances=True
训练的,则 OOB 排列变量重要性会显示在训练日志中。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-25。
[null,null,["最后更新时间 (UTC):2025-02-25。"],[[["\u003cp\u003eRandom forests utilize out-of-bag (OOB) evaluation, eliminating the need for a separate validation dataset by treating the training set as a test set in a cross-validation-like approach.\u003c/p\u003e\n"],["\u003cp\u003eOOB evaluation leverages the fact that each decision tree in the forest is trained on approximately 67% of the training data, allowing the remaining 33% to be used for evaluation, similar to a test set.\u003c/p\u003e\n"],["\u003cp\u003eDuring OOB evaluation, predictions for a specific example are generated using only the decision trees that did not include that example in their training process.\u003c/p\u003e\n"],["\u003cp\u003eYDF provides access to OOB evaluation metrics and OOB permutation variable importances within the training logs, offering insights into model performance and feature relevance.\u003c/p\u003e\n"]]],[],null,[]]