source: orange/docs/reference/rst/code/optimization-tuning1.py @ 9372:aef193695ea9

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

Moved documentation to the separate directory.

Line 
1import Orange
2
3learner = Orange.classification.tree.TreeLearner()
4data = Orange.data.Table("voting")
5tuner = Orange.optimization.Tune1Parameter(object=learner,
6                           parameter="minSubset",
7                           values=[1, 2, 3, 4, 5, 10, 15, 20],
8                           evaluate = Orange.evaluation.scoring.AUC, verbose=2)
9classifier = tuner(data)
10
11print "Optimal setting: ", learner.minSubset
12
13untuned = Orange.classification.tree.TreeLearner()
14res = Orange.evaluation.testing.cross_validation([untuned, tuner], data)
15AUCs = Orange.evaluation.scoring.AUC(res)
16
17print "Untuned tree: %5.3f" % AUCs[0]
18print "Tuned tree: %5.3f" % AUCs[1]
19
20learner = Orange.classification.tree.TreeLearner(minSubset=10).instance()
21data = Orange.data.Table("voting")
22tuner = Orange.optimization.Tune1Parameter(object=learner,
23                    parameter=["split.continuousSplitConstructor.minSubset", 
24                               "split.discreteSplitConstructor.minSubset"],
25                    values=[1, 2, 3, 4, 5, 10, 15, 20],
26                    evaluate = Orange.evaluation.scoring.AUC, verbose=2)
27
28classifier = tuner(data)
29
30print "Optimal setting: ", learner.split.continuousSplitConstructor.minSubset
Note: See TracBrowser for help on using the repository browser.