首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >决策树深度

决策树深度
EN

Stack Overflow用户
提问于 2016-10-25 13:54:10
回答 2查看 811关注 0票数 1

作为我的项目的一部分,我必须使用决策树,我使用的是“适配树”函数,这是Matlab函数的分类,我的特征提取与PCA。

我想在适配树函数中控制树的数、树的深度。有人知道我该怎么做吗?例如,将树的数目改为200棵,将树的深度改为10棵。我要怎么做?是否可以在决策树中更改这些值?

最好的

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-18 00:49:15

fitctree只提供用于控制结果树的深度的输入参数:

  • MaxNumSplits
  • MinLeafSize
  • MinParentSize

https://de.mathworks.com/help/stats/classification-trees-and-regression-trees.html#bsw6baj

你必须使用这些参数来控制你的树的深度。那是因为决策树只有在达到纯度时才停止生长。

另一种可能是开始修剪。剪枝将减少树的大小,方法是删除树中没有提供分类实例的能力的部分。

票数 2
EN

Stack Overflow用户

发布于 2016-12-12 16:26:35

让我假设您正在使用ID3算法。它的伪码可以提供一种控制树的深度的方法。

代码语言:javascript
复制
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

您的虚拟树函数尝试实现什么算法?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40241919

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档