Exemple #1
0
 def generateRules(self):
     self.error()
     self.warning(0)
     if self.dataset:
         if self.dataset and self.useSparseAlgorithm and not self.datasetIsSparse:
             self.warning(
                 0,
                 "Using algorithm for sparse data, but data does not appear to be sparse!"
             )
         try:
             num_steps = 20
             for i in range(num_steps):
                 build_support = (i == num_steps -
                                  1) and self.minSupport / 100. or (
                                      1 - float(i) / num_steps *
                                      (1 - self.minSupport / 100.0))
                 if self.useSparseAlgorithm:
                     rules = orange.AssociationRulesSparseInducer(
                         self.dataset,
                         support=build_support,
                         confidence=self.minConfidence / 100.,
                         storeExamples=True)
                 else:
                     rules = orange.AssociationRulesInducer(
                         self.dataset,
                         support=build_support,
                         confidence=self.minConfidence / 100.,
                         classificationRules=self.classificationRules,
                         storeExamples=True)
                 if len(rules) >= self.maxRules:
                     break
             self.send("Association Rules", rules)
         except orange.KernelException, (errValue):
             self.error(str(errValue))
             self.send("Association Rules", None)
Exemple #2
0
 def findItemsets(self):
     self.error()
     if self.dataset:
         try:
             if self.useSparseAlgorithm:
                 self.itemsets = orange.AssociationRulesSparseInducer(support = self.minSupport/100., storeExamples = True).getItemsets(self.dataset)
             else:
                 self.itemsets = orange.AssociationRulesInducer(support = self.minSupport/100., storeExamples = True).getItemsets(self.dataset)
             self.send("Itemsets", (self.dataset, self.itemsets))
         except Exception, (errValue):
             errValue = str(errValue)
             if "non-discrete attributes" in errValue and not self.useSparseAlgorithm:
                 errValue += "\nTry using the algorithm for sparse data"
             self.error(str(errValue))
             self.send("Itemsets", None)
Exemple #3
0
 def generateRules(self):
     self.error()
     if self.dataset:
         try:
             num_steps = 20
             for i in range(num_steps):
                 build_support = (i == num_steps-1) and self.minSupport/100. or (1 - float(i) / num_steps * (1 - self.minSupport/100.0))
                 if self.useSparseAlgorithm:
                     rules = orange.AssociationRulesSparseInducer(self.dataset, support = build_support, confidence = self.minConfidence/100., storeExamples = True)
                 else:
                     rules = orange.AssociationRulesInducer(self.dataset, support = build_support, confidence = self.minConfidence/100., classificationRules = self.classificationRules, storeExamples = True)
                 if len(rules) >= self.maxRules:
                     break
             self.send("Association Rules", rules)
         except orange.KernelException as errValue:
             self.error(str(errValue))
             self.send("Association Rules", None)
     else:
         self.send("Association Rules", None)
Exemple #4
0
import orange

data = orange.ExampleTable("inquisition")
rules = orange.AssociationRulesSparseInducer(data,
                                             support=0.5,
                                             storeExamples=True)

print "%5s   %5s" % ("supp", "conf")
for r in rules:
    print "%5.3f   %5.3f   %s" % (r.support, r.confidence, r)