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: Joins the elements in the frequent itemset and prunes
  resulting sets if they contain subsets that have been determined
  to be infrequent. 
docstr_tok: ["Joins","the","elements","in","the","frequent","itemset","and","prunes","resulting","sets","if","they","contain","subsets","that","have","been","determined","to","be","infrequent","."]
code: def _generate_candidates(self, freq_itemset):
      """Joins the elements in the frequent itemset and prunes
      resulting sets if they contain subsets that have been determined
      to be infrequent."""
      candidates = []
      for itemset1 in freq_itemset:
          for itemset2 in freq_itemset:
              # Valid if every element but the last are the same
              # and the last element in itemset1 is smaller than the last
              # in itemset2
              valid = False
              single_item = isinstance(itemset1, int)
              if single_item and itemset1 < itemset2:
                  valid = True
              elif (
                  not single_item
                  and np.array_equal(itemset1[:-1], itemset2[:-1])
                  and itemset1[-1] < itemset2[-1]
              ):
                  valid = True
  
              if valid:
                  # JOIN: Add the last element in itemset2 to itemset1 to
                  # create a new candidate
                  if single_item:
                      candidate = [itemset1, itemset2]
                  else:
                      candidate = itemset1 + [itemset2[-1]]
                  # PRUNE: Check if any subset of candidate have been determined
                  # to be infrequent
                  infrequent = self._has_infrequent_itemsets(candidate)
                  if not infrequent:
                      candidates.append(candidate)
      return candidates
  
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 5 for calling the Apriori obj's underlying member method code with example usage: obj._generate_candidates(freq_itemset) and returns: candidates