source: orange/docs/tutorial/rst/code/tree.py @ 9374:59bac7ddd8a2

Revision 9374:59bac7ddd8a2, 707 bytes checked in by mitar, 2 years ago (diff)

Tutorial documentation structure.

Line 
1# Description: Learn decision tree from data and output class probabilities for first few instances
2# Category:    modelling
3# Uses:        voting.tab
4# Classes:     orngTree.TreeLearner
5# Referenced:  c_otherclass.htm
6
7import orange, orngTree
8data = orange.ExampleTable("voting")
9
10tree = orngTree.TreeLearner(data, sameMajorityPruning=1, mForPruning=2)
11print "Possible classes:", data.domain.classVar.values
12print "Probabilities for democrats:"
13for i in range(5):
14    p = tree(data[i], orange.GetProbabilities)
15    print "%d: %5.3f (originally %s)" % (i+1, p[1], data[i].getclass())
16
17print
18orngTree.printTxt(tree)
19orngTree.printDot(tree, fileName='tree.dot', internalNodeShape="ellipse", leafShape="box")
20
Note: See TracBrowser for help on using the repository browser.