code: def generate_association_rules(patterns, confidence_threshold):
      
      rules = {}
      for itemset in patterns.keys():
          upper_support = patterns[itemset]
  
          for i in range(1, len(itemset)):
              for antecedent in itertools.combinations(itemset, i):
                  antecedent = tuple(sorted(antecedent))
                  consequent = tuple(sorted(set(itemset) - set(antecedent)))
  
                  if antecedent in patterns:
                      lower_support = patterns[antecedent]
                      confidence = float(upper_support) / lower_support
  
                      if confidence >= confidence_threshold:
                          rules[antecedent] = (consequent, confidence)
  
      return rules
docs: Given a set of frequent itemsets, return a dict
      of association rules in the form
      {(left): ((right), confidence)}