source: orange/orange/doc/modules/classification-rules2.py @ 7652:677f449144fd

Revision 7652:677f449144fd, 1.1 KB checked in by ales_erjavec <ales.erjavec@…>, 3 years ago (diff)
Line 
1# Description: Demonstrates the use of orngCN2 rules
2# Category:    classification, rules
3# Classes:     CN2Learner, CN2UnorderedLearner, CN2UnorderedLearner
4# Uses:        titanic.tab
5
6import orange
7import orngCN2
8
9data = orange.ExampleTable("titanic.tab")
10
11# create learner
12learner = orngCN2.CN2Learner()
13
14cl = learner(data)
15for r in cl.rules:
16    print orngCN2.ruleToString(r)
17print "*****"
18
19learner = orngCN2.CN2UnorderedLearner()
20
21learner.ruleFinder = orange.RuleBeamFinder()
22learner.ruleFinder.evaluator = orngCN2.mEstimate(m=50)
23
24cl = learner(data)
25for r in cl.rules:
26    print orngCN2.ruleToString(r)
27print "****"
28
29learner = orngCN2.CN2SDUnorderedLearner()
30
31learner.ruleFinder.ruleStoppingValidator = orange.RuleValidator_LRS(alpha=0.01,min_coverage=10,max_rule_complexity = 2)
32learner.ruleFinder.ruleFilter = orange.RuleBeamFilter_Width(width = 50)
33
34cl = learner(data)
35for r in cl.rules:
36    print orngCN2.ruleToString(r)
37print "****"
38
39learner = orngCN2.CN2UnorderedLearner()
40
41learner.ruleFinder = orange.RuleBeamFinder()
42learner.ruleFinder.evaluator = orngCN2.WRACCEvaluator()
43
44cl = learner(data)
45for r in cl.rules:
46    print orngCN2.ruleToString(r)
47print "****"
48
49
Note: See TracBrowser for help on using the repository browser.