作为我的项目的一部分,我必须使用决策树,我使用的是“适配树”函数,这是Matlab函数的分类,我的特征提取与PCA。
我想在适配树函数中控制树的数、和树的深度。有人知道我该怎么做吗?例如,将树的数目改为200棵,将树的深度改为10棵。我要怎么做?是否可以在决策树中更改这些值?
最好的
发布于 2016-12-18 00:49:15
fitctree只提供用于控制结果树的深度的输入参数:
https://de.mathworks.com/help/stats/classification-trees-and-regression-trees.html#bsw6baj
你必须使用这些参数来控制你的树的深度。那是因为决策树只有在达到纯度时才停止生长。
另一种可能是开始修剪。剪枝将减少树的大小,方法是删除树中没有提供分类实例的能力的部分。
发布于 2016-12-12 16:26:35
让我假设您正在使用ID3算法。它的伪码可以提供一种控制树的深度的方法。
ID3 (Examples, Target_Attribute, Attributes, **Depth**)
// Check the depth of the tree, if it is 0, we are going to break
if (Depth == 0) { break; }
// Else continue
Create a root node for the tree
If all examples are positive, Return the single-node tree Root, with label = +.
If all examples are negative, Return the single-node tree Root, with label = -.
If number of predicting attributes is empty, then Return the single node tree Root,
with label = most common value of the target attribute in the examples.
Otherwise Begin
A ← The Attribute that best classifies examples.
Decision Tree attribute for Root = A.
For each possible value, vi, of A,
Add a new tree branch below Root, corresponding to the test A = vi.
Let Examples(vi) be the subset of examples that have the value vi for A
If Examples(vi) is empty
Then below this new branch add a leaf node with label = most common target value in the examples
// We decrease the value of Depth by 1 so the tree stops growing when it reaches the designated depth
Else below this new branch add the subtree ID3 (Examples(vi), Target_Attribute, Attributes – {A}, Depth - 1)
End
Return Root您的虚拟树函数尝试实现什么算法?
https://stackoverflow.com/questions/40241919
复制相似问题