我们可以从 scikit-learn Gradient Boosted Decision Tree 中提取最终的决策规则吗?
Can we extract the final decision rules from scikit-learn Gradient Boosted Decision Tree?
我必须在 Python 中使用梯度引导决策树构建分类模型并获取模型参数(节点处的值)以在硬件上实现。据我了解,梯度提升决策树的最终结果是一个普通的决策树分类器,具有对输入数据进行分类的阈值。
我已阅读以下帖子:
正如他们所说,
model.estimators_
contains all the individual classifiers that the model consists of. In the case of a GradientBoostingClassifier, this is a 2D numpy array with shape (n_estimators, n_classes), and each item is a DecisionTreeRegressor.
他们展示了在构建梯度决策树分类器的过程中获取用作估计器的每个决策树的阈值的方法。我不确定 model.estimators
是否包含最终决策树。关于集成分类器的scikit-learn文档也没有提到。
请帮助我如何从 scikit-learn 中提取梯度提升决策树模型的最终参数(节点处的值)。
或者,如果我对 scikit-learn 中的梯度提升 DT 有一些误解,请告诉我。
I am not sure if model.estimators
contains the final decision tree or not [...] OR if I am misunderstanding something about the Gradient Boosted DT
看来您确实误解了一个关键细节:在 GBT 中 没有 任何 "final" 决策树; GBT的工作方式大致是:
- 集成中的每棵树根据自己的阈值进行分类
- 对集成中所有树的输出进行加权平均,以产生集成输出
来自您的评论:
My goal was getting the parameter of the tree which gave the best classification result
同样,这与提升无关,正如你在下一条评论中正确指出的那样,提升树顺序生长,每棵树专注于"mistakes" 前面的;但是
and the model achieved is a decision tree
不正确,正如我已经解释过的(最终模型是整个加法合奏)。因此,在这里选择任何一棵树都没有任何意义。
鉴于这些说明,您链接到的第一个线程给出了如何为 all 集合中的树提取规则(阈值)的确切方法(这将是老实说,不知道在实践中是否真的有用。
我必须在 Python 中使用梯度引导决策树构建分类模型并获取模型参数(节点处的值)以在硬件上实现。据我了解,梯度提升决策树的最终结果是一个普通的决策树分类器,具有对输入数据进行分类的阈值。
我已阅读以下帖子:
正如他们所说,
model.estimators_
contains all the individual classifiers that the model consists of. In the case of a GradientBoostingClassifier, this is a 2D numpy array with shape (n_estimators, n_classes), and each item is a DecisionTreeRegressor.
他们展示了在构建梯度决策树分类器的过程中获取用作估计器的每个决策树的阈值的方法。我不确定 model.estimators
是否包含最终决策树。关于集成分类器的scikit-learn文档也没有提到。
请帮助我如何从 scikit-learn 中提取梯度提升决策树模型的最终参数(节点处的值)。 或者,如果我对 scikit-learn 中的梯度提升 DT 有一些误解,请告诉我。
I am not sure if
model.estimators
contains the final decision tree or not [...] OR if I am misunderstanding something about the Gradient Boosted DT
看来您确实误解了一个关键细节:在 GBT 中 没有 任何 "final" 决策树; GBT的工作方式大致是:
- 集成中的每棵树根据自己的阈值进行分类
- 对集成中所有树的输出进行加权平均,以产生集成输出
来自您的评论:
My goal was getting the parameter of the tree which gave the best classification result
同样,这与提升无关,正如你在下一条评论中正确指出的那样,提升树顺序生长,每棵树专注于"mistakes" 前面的;但是
and the model achieved is a decision tree
不正确,正如我已经解释过的(最终模型是整个加法合奏)。因此,在这里选择任何一棵树都没有任何意义。
鉴于这些说明,您链接到的第一个线程给出了如何为 all 集合中的树提取规则(阈值)的确切方法(这将是老实说,不知道在实践中是否真的有用。