source: orange/docs/reference/rst/code/tree_c45.py @ 9823:7f9c3f3c6474

Revision 9823:7f9c3f3c6474, 1.2 KB checked in by lanumek, 2 years ago (diff)

Changed names of data sets (table replaced with data or name of the data set).

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
9iris = Orange.data.Table("iris")
10tree = Orange.classification.tree.C45Learner(iris)
11
12print "\n\nC4.5 with default arguments"
13for i in iris[:5]:
14    print tree(i), i.getclass()
15
16print "\n\nC4.5 with m=100"
17tree = Orange.classification.tree.C45Learner(iris, m=100)
18for i in iris[:5]:
19    print tree(i), i.getclass()
20
21print "\n\nC4.5 with minObjs=100"
22tree = Orange.classification.tree.C45Learner(iris, minObjs=100)
23for i in iris[: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(iris)
30for i in iris:
31    if i.getclass() != tree(i):
32        print i, tree(i)
33
34tree = Orange.classification.tree.C45Learner(iris)
35print tree
36print
37
38
39res = Orange.evaluation.testing.cross_validation([Orange.classification.tree.C45Learner(), 
40    Orange.classification.tree.C45Learner(convertToOrange=1)], iris)
41print "Classification accuracy: %5.3f (converted to tree: %5.3f)" % tuple(Orange.evaluation.scoring.CA(res))
42print "Brier score: %5.3f (converted to tree: %5.3f)" % tuple(Orange.evaluation.scoring.Brier_score(res))
Note: See TracBrowser for help on using the repository browser.