class_docstr: A method for determining frequent itemsets in a transactional database and
  also for generating rules for those itemsets. 
  
  Parameters:
  -----------
  min_sup: float
      The minimum fraction of transactions an itemets needs to
      occur in to be deemed frequent
  min_conf: float:
      The minimum fraction of times the antecedent needs to imply
      the concequent to justify rule
class_docstr_tok: ["A","method","for","determining","frequent","itemsets","in","a","transactional","database","and","also","for","generating","rules","for","those","itemsets",".","Parameters",":","--","--","--","--","--","-","min_sup",":","float","The","minimum","fraction","of","transactions","an","itemets","needs","to","occur","in","to","be","deemed","frequent","min_conf",":","float",":","The","minimum","fraction","of","times","the","antecedent","needs","to","imply","the","concequent","to","justify","rule"]
docstr: Recursive function which returns the rules where confidence >= min_confidence
  Starts with large itemset and recursively explores rules for subsets 
docstr_tok: ["Recursive","function","which","returns","the","rules","where","confidence",">","=","min_confidence","Starts","with","large","itemset","and","recursively","explores","rules","for","subsets"]
code: def _rules_from_itemset(self, initial_itemset, itemset):
      """Recursive function which returns the rules where confidence >= min_confidence
      Starts with large itemset and recursively explores rules for subsets
      """
      rules = []
      k = len(itemset)
      # Get all combinations of sub-itemsets of size k - 1 from itemset
      # E.g [1,2,3] => [[1,2],[1,3],[2,3]]
      subsets = list(itertools.combinations(itemset, k - 1))
      support = self._calculate_support(initial_itemset)
      for antecedent in subsets:
          # itertools.combinations returns tuples => convert to list
          antecedent = list(antecedent)
          antecedent_support = self._calculate_support(antecedent)
          # Calculate the confidence as sup(A and B) / sup(B), if antecedent
          # is B in an itemset of A and B
          confidence = float(
              "{0:.2f}".format(support / antecedent_support)
          )
          if confidence >= self.min_conf:
              # The concequent is the initial_itemset except for antecedent
              concequent = [
                  itemset
                  for itemset in initial_itemset
                  if not itemset in antecedent
              ]
              # If single item => get item
              if len(antecedent) == 1:
                  antecedent = antecedent[0]
              if len(concequent) == 1:
                  concequent = concequent[0]
              # Create new rule
              rule = Rule(
                  antecedent=antecedent,
                  concequent=concequent,
                  confidence=confidence,
                  support=support,
              )
              rules.append(rule)
  
              # If there are subsets that could result in rules
              # recursively add rules from subsets
              if k - 1 > 1:
                  rules += self._rules_from_itemset(
                      initial_itemset, antecedent
                  )
      return rules
  
file_path: ML-From-Scratch/mlfromscratch/unsupervised_learning/apriori.py
imports: from __future__ import division, print_function
  import numpy
  import itertools
label_desc: Use image node_id 8 for calling the Apriori obj's underlying member method code with example usage: obj._rules_from_itemset(initial_itemset, itemset) and returns: rules