Orange Forum • View topic - pre-pruning decision trees

pre-pruning decision trees

A place to ask questions about methods in Orange and how they are used and other general support.

pre-pruning decision trees

Hello,
When constructing decision trees, it is a good idea to limit the depth of the tree. As far as I udnerstand, this is done by mForPruning parameter. However, this parameter has no effect:

Code: Select all
`In [8]: import orange, orngTreeIn [9]: data = orange.ExampleTable('iris.tab')In [11]: for m in range(5):   ....:     t = orngTree.TreeLearner(data, mForPruning=m)   ....:     print m   ....:     orngTree.printTree(t)   ....:     print   ....:   ....:0petal width<=0.800: Iris-setosa (100.00%)petal width>0.800|    petal width<=1.750|    |    petal length>5.350: Iris-virginica (100.00%)|    |    petal length<=5.350|    |    |    petal length<=4.950|    |    |    |    petal width<=1.650: Iris-versicolor (100.00%)|    |    |    |    petal width>1.650: Iris-virginica (100.00%)|    |    |    petal length>4.950|    |    |    |    petal width<=1.550: Iris-virginica (100.00%)|    |    |    |    petal width>1.550: Iris-versicolor (100.00%)|    petal width>1.750|    |    petal length>4.850: Iris-virginica (100.00%)|    |    petal length<=4.850|    |    |    sepal width<=3.100: Iris-virginica (100.00%)|    |    |    sepal width>3.100: Iris-versicolor (100.00%)1petal width<=0.800: Iris-setosa (100.00%)petal width>0.800|    petal width<=1.750|    |    petal length>5.350: Iris-virginica (100.00%)|    |    petal length<=5.350|    |    |    petal length<=4.950|    |    |    |    petal width<=1.650: Iris-versicolor (100.00%)|    |    |    |    petal width>1.650: Iris-virginica (100.00%)|    |    |    petal length>4.950|    |    |    |    petal width<=1.550: Iris-virginica (100.00%)|    |    |    |    petal width>1.550: Iris-versicolor (100.00%)|    petal width>1.750|    |    petal length>4.850: Iris-virginica (100.00%)|    |    petal length<=4.850|    |    |    sepal width<=3.100: Iris-virginica (100.00%)|    |    |    sepal width>3.100: Iris-versicolor (100.00%)2petal width<=0.800: Iris-setosa (100.00%)petal width>0.800|    petal width>1.750: Iris-virginica (97.83%)|    petal width<=1.750|    |    petal length>5.350: Iris-virginica (100.00%)|    |    petal length<=5.350|    |    |    petal length<=4.950|    |    |    |    petal width<=1.650: Iris-versicolor (100.00%)|    |    |    |    petal width>1.650: Iris-virginica (100.00%)|    |    |    petal length>4.950|    |    |    |    petal width<=1.550: Iris-virginica (100.00%)|    |    |    |    petal width>1.550: Iris-versicolor (100.00%)`

What am I doing wrong?

Use maxDepth parameter to limit tree depth (http://www.ailab.si/orange/doc/reference/TreeLearner.htm)

Code: Select all
`for m in range(5):     print m     print orngTree.printTree(orngTree.TreeLearner(data, maxDepth=m)) `

Return to Questions & Support