source: orange/orange/doc/modules/tree4.py @ 2381:7b86e0e1ccfd

Revision 2381:7b86e0e1ccfd, 832 bytes checked in by janezd <janez.demsar@…>, 7 years ago (diff)
  • printing out the trees has been completely rewritten, and documentation and the scripts changed accordingly
RevLine 
[526]1# Author:      J Zabkar
2# Version:     1.0
3# Description: Storing and printing out the examples in classification tree
4# Category:    modelling
5# Uses:        iris.tab
[952]6# Referenced:   orngTree.htm
[526]7
8import orange, orngTree
9
10def printExamples(node):
11    if node:
12        if node.branches:
13            for b in node.branches:
14                printExamples(b)
15        else:
16            print "----------------- NEW NODE -----------------"
17            for ex in node.examples:
18                print ex
19    else:
20        print "null node"
21
22
23data = orange.ExampleTable("iris.tab")
24print len(data)
25
26tree = orngTree.TreeLearner(data, storeExamples=1, storeContingencies=1)
[2381]27print 'CLASSIFICATION TREE:'
[526]28orngTree.printTxt(tree)
29
30print '\nEXAMPLES IN NODES:'
31printExamples(tree.tree)
32
33print '\nCONTINGENCY:'
34print tree.tree.contingency.classes
Note: See TracBrowser for help on using the repository browser.