source: orange/Orange/testing/regression/tests_20/reference_c45.py @ 10671:e7941be8ecbc

Revision 10671:e7941be8ecbc, 1.1 KB checked in by anze <anze.staric@…>, 2 years ago (diff)

Fixed output.

Line 
1# Description: Shows how to use C4.5 learner
2# Category:    learning
3# Classes:     C45Learner, C45Classifier
4# Uses:        iris
5# Referenced:  C45Learner.htm
6
7import orange
8
9data = orange.ExampleTable("iris")
10tree = orange.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.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.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.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
34
35import orngC45
36tree = orange.C45Learner(data)
37orngC45.printTree(tree)
38print
39
40import orngStat, orngTest
41res = orngTest.crossValidation([orange.C45Learner(), orange.C45Learner(convertToOrange=1)], data)
42print "Classification accuracy: %5.3f (converted to tree: %5.3f)" % tuple(orngStat.CA(res))
43print "Brier score: %5.3f (converted to tree: %5.3f)" % tuple(orngStat.BrierScore(res))
Note: See TracBrowser for help on using the repository browser.