source: orange/docs/tutorial/rst/code/assoc2.py @ 11054:eca373fb96a9

Revision 11054:eca373fb96a9, 926 bytes checked in by blaz <blaz.zupan@…>, 16 months ago (diff)

new tutorial (refresh after removal of old files)

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 orngAssoc
8import Orange
9
10data = Orange.data.Table("imports-85")
11data = Orange.data.preprocess.Discretize(data, \
12  method=Orange.data.discretization.EqualFreq(numberOfIntervals=3))
13data = data.select(range(10))
14
15rules = Orange.associate.AssociationRulesInducer(data, support=0.4)
16
17n = 5
18print "%i most confident rules:" % (n)
19orngAssoc.sort(rules, ["confidence", "support"])
20orngAssoc.printRules(rules[0:n], ['confidence', 'support', 'lift'])
21
22conf = 0.8; lift = 1.1
23print "\nRules with confidence>%5.3f and lift>%5.3f" % (conf, lift)
24rulesC = rules.filter(lambda x: x.confidence > conf and x.lift > lift)
25orngAssoc.sort(rulesC, ['confidence'])
26orngAssoc.printRules(rulesC, ['confidence', 'support', 'lift'])
Note: See TracBrowser for help on using the repository browser.