【问题标题】:Decision Tree Depth决策树深度
【发布时间】:2017-03-07 14:49:55
【问题描述】:

作为我项目的一部分,我必须使用决策树,我正在使用“fitctree”函数,该函数是 Matlab 函数,用于对使用 PCA 提取的特征进行分类。

我想在 fitctree 函数中控制 树的数量树的深度。 有谁知道我该怎么做?例如,将树的数量更改为 200,将树的深度更改为 10。我该怎么做? 是否可以在决策树中更改这些值?

最好的,

【问题讨论】:

    标签: cart decision-tree


    【解决方案1】:

    假设您使用的是 ID3 算法。它的pseudocode 可以提供一种控制树深度的方法。

    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
    

    你的 fictree 函数尝试实现什么算法?

    【讨论】:

      【解决方案2】:

      fitctree 仅提供输入参数来控制生成树的深度:

      • MaxNumSplits
      • MinLeafSize
      • MinParentSize

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

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

      另一种可能性是打开修剪。修剪将通过删除树中对实例分类提供很少能力的部分来减小树的大小。

      【讨论】:

      • 如何构建具有我想要的深度的树?例如,我想创建一个只有 3 深度的决策树。
      猜你喜欢
      • 2016-10-18
      • 2018-09-21
      • 2017-01-21
      • 2019-03-10
      • 2023-04-08
      • 2017-10-05
      • 2019-06-27
      • 2020-05-19
      • 2022-01-27
      相关资源
      最近更新 更多