Ignore:
Timestamp:
04/18/12 15:02:19 (2 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Message:

Fixed Association Rules Explorer to show rules from sparse data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/Associate/OWAssociationRulesTreeViewer.py

    r9671 r10810  
    234234    def arules(self,arules): 
    235235        self.origRules = arules 
    236         self.rules=[(set(str(val.variable.name) + (val.varType and "=" + str(val) or "") for val in rule.left if not val.isSpecial()), 
    237                      "  ".join(str(val.variable.name) + (val.varType and "=" + str(val) or "") for val in rule.right if not val.isSpecial()), 
    238                      (rule.support, rule.confidence, rule.lift, rule.leverage, rule.strength, rule.coverage), 
    239                      id 
    240                      ) 
    241                     for id, rule in enumerate(arules or [])] 
     236        if not arules: 
     237            self.rules = [] 
     238        elif arules[0].left.domain.attributes: 
     239                self.rules=[(set(str(val.variable.name) + (val.varType and "=" + str(val) or "") for val in rule.left if not val.isSpecial()), 
     240                             "  ".join(str(val.variable.name) + (val.varType and "=" + str(val) or "") for val in rule.right if not val.isSpecial()), 
     241                             (rule.support, rule.confidence, rule.lift, rule.leverage, rule.strength, rule.coverage), 
     242                             id 
     243                             ) 
     244                            for id, rule in enumerate(arules)] 
     245        else: # sparse rules 
     246            self.rules = [(set(rule.left.get_metas(str)), " ".join(rule.right.get_metas(str)), 
     247                           (rule.support, rule.confidence, rule.lift, rule.leverage, rule.strength, rule.coverage), 
     248                           id) 
     249                for id, rule in enumerate(arules) 
     250            ] 
    242251        self.displayRules() 
    243252        self.selectionChanged() 
Note: See TracChangeset for help on using the changeset viewer.