source: orange/Orange/doc/ofb/assoc2.py @ 9671:a7b056375472

Revision 9671:a7b056375472, 880 bytes checked in by anze <anze.staric@…>, 2 years ago (diff)

Moved orange to Orange (part 2)

Line 
1# Description: Association rule sorting and filtering
2# Category:    description
3# Uses:        imports-85
4# Classes:     orngAssoc.build, Preprocessor_discretize, EquiNDiscretization
5# Referenced:  assoc.htm
6
7import orange, orngAssoc
8
9data = orange.ExampleTable("imports-85")
10data = orange.Preprocessor_discretize(data, \
11  method=orange.EquiNDiscretization(numberOfIntervals=3))
12data = data.select(range(10))
13
14rules = orange.AssociationRulesInducer(data, support = 0.4)
15
16n = 5
17print "%i most confident rules:" % (n)
18orngAssoc.sort(rules, ["confidence"])
19orngAssoc.printRules(rules[0:n], ['confidence','support','lift'])
20
21conf = 0.8; lift = 1.1
22print "\nRules with confidence>%5.3f and lift>%5.3f" % (conf, lift)
23rulesC=rules.filter(lambda x: x.confidence>conf and x.lift>lift)
24orngAssoc.sort(rulesC, ['confidence'])
25orngAssoc.printRules(rulesC, ['confidence','support','lift'])
Note: See TracBrowser for help on using the repository browser.