def main(): data = orange.ExampleTable(join(util.module_path(), "f_assoc")) data = orange.Preprocessor_discretize(data, method=orange.EquiNDiscretization(numberOfIntervals=4)) rules = orange.AssociationRulesInducer(data, support=0.2) orngAssoc.sort(rules, ["confidence", "support"]) orngAssoc.printRules(rules, ["support", "confidence"])
def startMining(self, var, sup): data = orange.ExampleTable("data/finalData.csv") #was47 data = data.select(range(44)) minSupport = float(sup) rules = orange.AssociationRulesInducer(data, support=minSupport, max_item_sets=30000000) print "%i rules with support higher than or equal to %5.3f found." % ( len(rules), minSupport) orngAssoc.printRules(rules[:10], ["support", "confidence"])
def startMining(self, var, sup): data = orange.ExampleTable("data/finalData.csv") #was47 data = data.select(range(44)) minSupport = float(sup) rules = orange.AssociationRulesInducer(data, support = minSupport, max_item_sets = 30000000) print "%i rules with support higher than or equal to %5.3f found." % (len(rules), minSupport) orngAssoc.printRules(rules[:10], ["support", "confidence"])
def startMining(self, var): data = orange.ExampleTable("data/finalData.csv") #was47 data = data.select(range(44)) minSupport = 0.4 rules = orange.AssociationRulesInducer(data, support = minSupport, max_item_sets = 30000000) orig_stdout = sys.stdout f = open('results/{}_assocrules.txt'.format(var), 'w') sys.stdout = f print "%i rules with support higher than or equal to %5.3f found." % (len(rules), minSupport) orngAssoc.printRules(rules[:10], ["support", "confidence"]) > f sys.stdout = orig_stdout f.close()
import Orange, orngAssoc data = Orange.data.Table("TermPost.basket") rules = Orange.associate.AssociationRulesSparseInducer(data, support=0.05) orngAssoc.sort(rules, ["confidence","support"]) orngAssoc.printRules(rules[100:200], ["support", "confidence"]) #print "%4s %4s %s" % ("Supp", "Conf", "Rule") #for r in rules[:500]: # print "%4.1f %4.1f %s" % (r.support, r.confidence, r)
# Description: Association rule sorting and filtering # Category: description # Uses: imports-85 # Classes: orngAssoc.build, Preprocessor_discretize, EquiNDiscretization # Referenced: assoc.htm import orange, orngAssoc data = orange.ExampleTable("imports-85") data = orange.Preprocessor_discretize(data, \ method=orange.EquiNDiscretization(numberOfIntervals=3)) data = data.select(range(10)) rules = orange.AssociationRulesInducer(data, support=0.4) n = 5 print "%i most confident rules:" % (n) orngAssoc.sort(rules, ["confidence", "support"]) orngAssoc.printRules(rules[0:n], ['confidence', 'support', 'lift']) conf = 0.8 lift = 1.1 print "\nRules with confidence>%5.3f and lift>%5.3f" % (conf, lift) rulesC = rules.filter(lambda x: x.confidence > conf and x.lift > lift) orngAssoc.sort(rulesC, ['confidence']) orngAssoc.printRules(rulesC, ['confidence', 'support', 'lift'])
# Description: Association rule sorting and filtering # Category: description # Uses: imports-85 # Classes: orngAssoc.build, Preprocessor_discretize, EquiNDiscretization # Referenced: assoc.htm import orange, orngAssoc data = orange.ExampleTable("imports-85") data = orange.Preprocessor_discretize(data, \ method=orange.EquiNDiscretization(numberOfIntervals=3)) data = data.select(range(10)) rules = orange.AssociationRulesInducer(data, support = 0.4) n = 5 print "%i most confident rules:" % (n) orngAssoc.sort(rules, ["confidence"]) orngAssoc.printRules(rules[0:n], ['confidence','support','lift']) conf = 0.8; lift = 1.1 print "\nRules with confidence>%5.3f and lift>%5.3f" % (conf, lift) rulesC=rules.filter(lambda x: x.confidence>conf and x.lift>lift) orngAssoc.sort(rulesC, ['confidence']) orngAssoc.printRules(rulesC, ['confidence','support','lift'])
import Orange, orngAssoc data = Orange.data.Table("TermPost.basket") rules = Orange.associate.AssociationRulesSparseInducer(data, support=0.05) orngAssoc.sort(rules, ["confidence", "support"]) orngAssoc.printRules(rules[100:200], ["support", "confidence"]) #print "%4s %4s %s" % ("Supp", "Conf", "Rule") #for r in rules[:500]: # print "%4.1f %4.1f %s" % (r.support, r.confidence, r)
# Description: Creates a list of association rules, selects five rules and prints them out # Category: description # Uses: imports-85 # Classes: orngAssoc.build, Preprocessor_discretize, EquiNDiscretization # Referenced: assoc.htm import orange, orngAssoc data = orange.ExampleTable("imports-85") data = orange.Preprocessor_discretize(data, \ method=orange.EquiNDiscretization(numberOfIntervals=3)) data = data.select(range(10)) rules = orange.AssociationRulesInducer(data, support=0.4) print "%i rules with support higher than or equal to %5.3f found.\n" % (len(rules), 0.4) orngAssoc.sort(rules, ["support", "confidence"]) orngAssoc.printRules(rules[:5], ["support", "confidence"]) print del rules[:3] orngAssoc.printRules(rules[:5], ["support", "confidence"]) print