我仍然不完全理解sklearn
分类器中的max_features
。这个documentation给解释留下了一点空间。出于这个问题的目的,假设我正在使用一个基于树的分类器,例如决策树、随机林、梯度提升等等
例如,如果我要设置max_features=10
,这是否意味着每个估计器将从我的数据集中随机抽取10个特征来构建整个树,还是意味着每次分割节点时,每个估计器都会随机抽取10个特征,并选择熵降低最大的特征
我的理解是,在整个过程中,单个估计员将自己限制为10个变量。然而,似乎在每个节点上重置了最大数量的功能。也就是说,对于任何给定节点,估计器随机选择10个特征,选择最佳特征,分割节点,并对所有后续节点重复该过程
from sklearn.ensemble import GradientBoostingClassifier
clf = GradientBoostingClassifier(max_features=10, n_estimators=150)
你在这里的理解是正确的。梯度提升和随机森林的工作方式是,在每个树的每个分割处,他们将随机选择
max_features
(在文献中,该参数称为mtry
)进行评估。这是一种机制,通过该机制,模型通过在每次分割时不评估每个特征而在模型之间引入随机性作为TG61591答案的补充,如果您深入研究code,您可以找到一条附加注释,该注释添加了一些关于
max_features
超参数在模型中如何工作的有用信息:此外,关键概念是随机森林需要增加随机性,以减少模型的方差(尽管这可能会导致更高的偏差),正如本最后说明中所警告的:
相关问题 更多 >
编程相关推荐