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

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

Tests moved and renamed from orange 20.

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.