def association_rules(dataset, freqsets, support, minlift):
 nr_transactions = float(len(dataset))
 freqsets = [f for f in freqsets if (len(f) > 1)]
 for fset in freqsets:
  for f in fset:
   consequent = frozenset([f])
   antecendent = (fset - consequent)
   py_x = (support[fset] / support[antecendent])
   base = (support[consequent] / nr_transactions)
   lift = (py_x / base)
   if (lift > minlift):
    (yield AssociationRule(antecendent, consequent, base, py_x, lift))

def association_rules ( dataset , freqsets , support , minlift ) : nr_transactions = float ( len ( dataset ) ) freqsets = [ f for f in freqsets if ( len ( f ) > 1 ) ] for fset in freqsets : for f in fset : consequent = frozenset ( [ f ] ) antecendent = ( fset - consequent ) py_x = ( support [ fset ] / support [ antecendent ] ) base = ( support [ consequent ] / nr_transactions ) lift = ( py_x / base ) if ( lift > minlift ) : ( yield AssociationRule ( antecendent , consequent , base , py_x , lift ) )
for assoc_rule in association_rules: this function takes the returns from apriori .