source: orange/orange/doc/Orange/rst/code/tree_c45.py @ 7755:6e519f6df8fe

Revision 7755:6e519f6df8fe, 1.2 KB checked in by markotoplak, 3 years ago (diff)

Removed references to printTreeC45.

Line 
1# Description: Shows how to use C4.5 learner
2# Category:    learning
3# Classes:     C45Learner, C45Classifier
4# Uses:        iris
5# Referenced:  TODO
6
7import Orange
8
9data = Orange.data.Table("iris")
10tree = Orange.classification.tree.C45Learner(data)
11
12print "\n\nC4.5 with default arguments"
13for i in data[:5]:
14    print tree(i), i.getclass()
15
16print "\n\nC4.5 with m=100"
17tree = Orange.classification.tree.C45Learner(data, m=100)
18for i in data[:5]:
19    print tree(i), i.getclass()
20
21print "\n\nC4.5 with minObjs=100"
22tree = Orange.classification.tree.C45Learner(data, minObjs=100)
23for i in data[:5]:
24    print tree(i), i.getclass()
25
26print "\n\nC4.5 with -m 1 and -s"
27lrn = Orange.classification.tree.C45Learner()
28lrn.commandline("-m 1 -s")
29tree = lrn(data)
30for i in data:
31    if i.getclass() != tree(i):
32        print i, tree(i)
33
34tree = Orange.classification.tree.C45Learner(data)
35print tree.dump()
36print
37
38import orngStat, orngTest
39res = orngTest.crossValidation([Orange.classification.tree.C45Learner(), 
40    Orange.classification.tree.C45Learner(convertToOrange=1)], data)
41print "Classification accuracy: %5.3f (converted to tree: %5.3f)" % tuple(orngStat.CA(res))
42print "Brier score: %5.3f (converted to tree: %5.3f)" % tuple(orngStat.BrierScore(res))
Note: See TracBrowser for help on using the repository browser.