【发布时间】:2013-06-26 02:25:45
【问题描述】:
全部!
谁能给我一个关于在 Python 中实现随机森林的建议?理想情况下,我需要输出尽可能多的分类器信息,尤其是:
- 训练集中的哪些向量用于训练每个决策 树木
- 在每个节点的每个节点中随机选择哪些特征 树,来自训练集的样本最终在这个节点中, 选择特征进行拆分以及使用哪个阈值 拆分
我发现了很多实现,最著名的可能来自 scikit,但不清楚如何在其中执行 (1) 和 (2)(请参阅this 问题)。其他实现似乎也有同样的问题,除了来自 openCV 的那个,但它是用 C++ 编写的(python 接口不涵盖随机森林的所有方法)。
有人知道满足 (1) 和 (2) 的东西吗?或者,知道如何改进 scikit 实现以获得功能 (1) 和 (2)?
已解决:查看了sklearn.tree._tree.Tree的源码。它有很好的 cmets(完全描述了树):
children_left : int*
children_left[i] holds the node id of the left child of node i.
For leaves, children_left[i] == TREE_LEAF. Otherwise,
children_left[i] > i. This child handles the case where
X[:, feature[i]] <= threshold[i].
children_right : int*
children_right[i] holds the node id of the right child of node i.
For leaves, children_right[i] == TREE_LEAF. Otherwise,
children_right[i] > i. This child handles the case where
X[:, feature[i]] > threshold[i].
feature : int*
feature[i] holds the feature to split on, for the internal node i.
threshold : double*
threshold[i] holds the threshold for the internal node i.
【问题讨论】:
标签: python scikit-learn random-forest