| 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
|
| Rev | Line | |
|---|
| [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 | |
|---|
| 8 | import orange, orngTree |
|---|
| 9 | |
|---|
| 10 | def 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 | |
|---|
| 23 | data = orange.ExampleTable("iris.tab") |
|---|
| 24 | print len(data) |
|---|
| 25 | |
|---|
| 26 | tree = orngTree.TreeLearner(data, storeExamples=1, storeContingencies=1) |
|---|
| [2381] | 27 | print 'CLASSIFICATION TREE:' |
|---|
| [526] | 28 | orngTree.printTxt(tree) |
|---|
| 29 | |
|---|
| 30 | print '\nEXAMPLES IN NODES:' |
|---|
| 31 | printExamples(tree.tree) |
|---|
| 32 | |
|---|
| 33 | print '\nCONTINGENCY:' |
|---|
| 34 | print tree.tree.contingency.classes |
|---|
Note: See
TracBrowser
for help on using the repository browser.