python - 获取 GBDT 模型树信息的信息
问题描述
我正在使用sklearn learn的 GBDT,我想知道有没有办法获得最终训练的 GBDT 树信息?我的理解是,如果我为每棵树设置最大 500 棵树和最大 10 深度,这是一个上限,我想获得实际使用的树数和每棵树的实际深度。
解决方案
您链接到的文档页面列出了以下属性:
estimators_ : ndarray of DecisionTreeRegressor,shape (n_estimators, loss_.K)
The collection of fitted sub-estimators. loss_.K is 1 for binary classification, otherwise n_classes.
因此,您应该能够按照添加到模型中的顺序获取单个树。
附加说明:模型中使用的实际树数将等于一个参数n_estimators
,除非使用提前停止,否则它可能会更少,并且存储在以下属性中:
n_estimators_ : int
The number of estimators as selected by early stopping (if n_iter_no_change is specified). Otherwise it is set to n_estimators
深度最大化,除非每个叶子/分割和其他参数限制没有足够的样本。
推荐阅读
- angular - Angular 8 多个 mat-checkbox 需要验证
- django - Django模板 - 如何在给定索引号(由迭代器生成)的表单(上下文)中访问表单
- python - celery 任务中的数据库已过时
- .net-core - .Net Core 2.0 返回 BadRequestObjectResult 导致 Newtonsoft.Json.JsonSerializationException:检测到自引用循环
- sql - 从行和列中的 Json 数组中获取数据
- android - MultiAutoCompleteTextView android限制用户多次选择相同的值
- c++ - 在类中使用随机生成器时的性能问题
- python - 访问主页时出现 Pythonanywhere 错误
- android - 如何从 Kotlin 中的内部类 [AsyncTask] 访问扩展功能?
- .net - 如何在 API 管理中配置 Azure AAD 并从 .NET 中的 Web/控制台应用程序调用 API 管理端点