source: orange/orange/doc/ofb-rst/code/tree.py @ 6866:e644c787d036

Revision 6866:e644c787d036, 707 bytes checked in by blaz <blaz.zupan@…>, 3 years ago (diff)

python scripts and images for ofb

RevLine 
[6866]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.