source: orange/Orange/doc/modules/tree4.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 788 bytes checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1# Description: Storing and printing out the examples in classification tree
2# Category:    modelling
3# Uses:        iris.tab
4# Referenced:  orngTree.htm
5
6import orange, orngTree
7
8def printExamples(node):
9    if node:
10        if node.branches:
11            for b in node.branches:
12                printExamples(b)
13        else:
14            print "----------------- NEW NODE -----------------"
15            for ex in node.examples:
16                print ex
17    else:
18        print "null node"
19
20
21data = orange.ExampleTable("iris.tab")
22print len(data)
23
24tree = orngTree.TreeLearner(data, storeExamples=1, storeContingencies=1)
25print 'CLASSIFICATION TREE:'
26orngTree.printTxt(tree)
27
28print '\nEXAMPLES IN NODES:'
29printExamples(tree.tree)
30
31print '\nCONTINGENCY:'
32print tree.tree.contingency.classes
Note: See TracBrowser for help on using the repository browser.