source: orange/Orange/testing/regression/tests_20/modules_tree8.py @ 9952:986e9cd806f4

Revision 9952:986e9cd806f4, 695 bytes checked in by Miha Stajdohar <miha.stajdohar@…>, 2 years ago (diff)

Tests moved and renamed from orange 20.

Line 
1# Description: Builds a classification tree, and prunes it using minimal error
2#              prunning with different values of parameter m. Prints
3#              out m and the size of the tree.
4#              a tree in text and dot format
5# Category:    modelling
6# Uses:        iris
7# Referenced:  orngTree.htm
8
9import orange, orngTree
10data = orange.ExampleTable("../datasets/adult_sample.tab")
11
12tree = orange.TreeLearner(data)
13prunner = orange.TreePruner_m()
14trees = [(0, tree.tree)]
15for m in [0.0, 0.1, 0.5, 1, 5, 10, 50, 100]:
16    prunner.m = m
17    trees.append((m, prunner(tree)))
18
19for m, t in trees:
20    print "m = %5.3f: %i nodes, %i leaves" % (m, t.treesize(), orngTree.countLeaves(t))
Note: See TracBrowser for help on using the repository browser.