首页 > 解决方案 > 获取 GBDT 模型树信息的信息

问题描述

我正在使用sklearn learn的 GBDT,我想知道有没有办法获得最终训练的 GBDT 树信息?我的理解是,如果我为每棵树设置最大 500 棵树和最大 10 深度,这是一个上限,我想获得实际使用的树数和每棵树的实际深度。

标签: pythonmachine-learningscikit-learn

解决方案


您链接到的文档页面列出了以下属性:

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

深度最大化,除非每个叶子/分割和其他参数限制没有足够的样本。


推荐阅读