source: orange/docs/reference/rst/code/orngTree1.py @ 9372:aef193695ea9

Revision 9372:aef193695ea9, 1.0 KB checked in by mitar, 2 years ago (diff)

Moved documentation to the separate directory.

Line 
1import Orange
2
3data = Orange.data.Table("iris")
4tree = Orange.classification.tree.TreeLearner(data, max_depth=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.format(leaf_str=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.format(leaf_str=fl, node_str=fn)
17
18
19data = Orange.data.Table("housing")
20tree = Orange.classification.tree.TreeLearner(data, max_depth=3)
21formats = ["", "%V"]
22for format in formats:
23    print '\n\n*** FORMAT: "%s"\n' % format
24    print tree.format(leaf_str=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.format(leaf_str=fl, node_str=fn)
Note: See TracBrowser for help on using the repository browser.