source: orange/orange/doc/Orange/rst/code/orngTree1.py @ 7713:d27afc892c9c

Revision 7713:d27afc892c9c, 1.0 KB checked in by markotoplak, 3 years ago (diff)

Tree documentation update.

Line 
1import Orange
2
3data = Orange.data.Table("iris")
4tree = Orange.classification.tree.TreeLearner(data, maxDepth=3)
5
6formats = ["", "%V (%M out of %N)", "%V (%^MbA%, %^MbP%)",
7           '%C="Iris-versicolor" (%^c="Iris-versicolor"% of node, %^CbA="Iris-versicolor"% of versicolors)',
8           "%D", "%.2d"]
9
10for format in formats:
11    print '\n\n*** FORMAT: "%s"\n' % format
12    print tree.dump(leafStr=format)
13
14formats2 = [("%V", "."), ('%^.1CbA="Iris-virginica"% (%^.1CbP="Iris-virginica"%)', '.'), ("%V   %D %.2DbP %.2dbP", "%D %.2DbP %.2dbP")]
15for fl, fn in formats2:
16    print tree.dump(leafStr=fl, nodeStr=fn)
17
18
19data = Orange.data.Table("housing")
20tree = Orange.classification.tree.TreeLearner(data, maxDepth=3)
21formats = ["", "%V"]
22for format in formats:
23    print '\n\n*** FORMAT: "%s"\n' % format
24    print tree.dump(leafStr=format)
25
26formats2 = [("[SE: %E]\t %V %I(90)", "[SE: %E]"), ("%C<22 (%cbP<22)", "."), ("%C![20,22] (%^cbP![20,22]%)", ".")]
27for fl, fn in formats2:
28    print tree.dump(leafStr=fl, nodeStr=fn)
Note: See TracBrowser for help on using the repository browser.