class_docstr: Encoder class for transaction data in Python lists
  
  Parameters
  ------------
  None
  
  Attributes
  ------------
  columns_: list
    List of unique names in the `X` input list of lists
  
  Examples
  ------------
  For usage examples, please see
  https://rasbt.github.io/mlxtend/user_guide/preprocessing/TransactionEncoder/
docstr: Transform transactions into a one-hot encoded NumPy array.
  
  Parameters
  ------------
  X : list of lists
    A python list of lists, where the outer list stores the
    n transactions and the inner list stores the items in each
    transaction.
  
    For example,
    [['Apple', 'Beer', 'Rice', 'Chicken'],
     ['Apple', 'Beer', 'Rice'],
     ['Apple', 'Beer'],
     ['Apple', 'Bananas'],
     ['Milk', 'Beer', 'Rice', 'Chicken'],
     ['Milk', 'Beer', 'Rice'],
     ['Milk', 'Beer'],
     ['Apple', 'Bananas']]
  
  sparse: bool (default=False)
    If True, transform will return Compressed Sparse Row matrix
    instead of the regular one.
  
  Returns
  ------------
  array : NumPy array [n_transactions, n_unique_items]
     if sparse=False (default).
     Compressed Sparse Row matrix otherwise
     The one-hot encoded boolean array of the input transactions,
     where the columns represent the unique items found in the input
     array in alphabetic order. Exact representation depends
     on the sparse argument
  
     For example,
     array([[True , False, True , True , False, True ],
            [True , False, True , False, False, True ],
            [True , False, True , False, False, False],
            [True , True , False, False, False, False],
            [False, False, True , True , True , True ],
            [False, False, True , False, True , True ],
            [False, False, True , False, True , False],
            [True , True , False, False, False, False]])
    The corresponding column labels are available as self.columns_, e.g.,
    ['Apple', 'Bananas', 'Beer', 'Chicken', 'Milk', 'Rice']
docstr_tok: ["Transform","transactions","into","a","one-hot","encoded","NumPy","array",".","Parameters","--","--","--","--","--","--","X",":","list","of","lists","A","python","list","of","lists",",","where","the","outer","list","stores","the","n","transactions","and","the","inner","list","stores","the","items","in","each","transaction",".","For","example",",","[","[","'Apple","'",",","'Beer","'",",","'Rice","'",",","'Chicken","'","]",",","[","'Apple","'",",","'Beer","'",",","'Rice","'","]",",","[","'Apple","'",",","'Beer","'","]",",","[","'Apple","'",",","'Bananas","'","]",",","[","'Milk","'",",","'Beer","'",",","'Rice","'",",","'Chicken","'","]",",","[","'Milk","'",",","'Beer","'",",","'Rice","'","]",",","[","'Milk","'",",","'Beer","'","]",",","[","'Apple","'",",","'Bananas","'","]","]","sparse",":","bool","(","default=False",")","If","True",",","transform","will","return","Compressed","Sparse","Row","matrix","instead","of","the","regular","one",".","Returns","--","--","--","--","--","--","array",":","NumPy","array","[","n_transactions",",","n_unique_items","]","if","sparse=False","(","default",")",".","Compressed","Sparse","Row","matrix","otherwise","The","one-hot","encoded","boolean","array","of","the","input","transactions",",","where","the","columns","represent","the","unique","items","found","in","the","input","array","in","alphabetic","order",".","Exact","representation","depends","on","the","sparse","argument","For","example",",","array","(","[","[","True",",","False",",","True",",","True",",","False",",","True","]",",","[","True",",","False",",","True",",","False",",","False",",","True","]",",","[","True",",","False",",","True",",","False",",","False",",","False","]",",","[","True",",","True",",","False",",","False",",","False",",","False","]",",","[","False",",","False",",","True",",","True",",","True",",","True","]",",","[","False",",","False",",","True",",","False",",","True",",","True","]",",","[","False",",","False",",","True",",","False",",","True",",","False","]",",","[","True",",","True",",","False",",","False",",","False",",","False","]","]",")","The","corresponding","column","labels","are","available","as","self.columns_",",","e.g.",",","[","'Apple","'",",","'Bananas","'",",","'Beer","'",",","'Chicken","'",",","'Milk","'",",","'Rice","'","]"]
code: def transform(self, X, sparse=False):
      """Transform transactions into a one-hot encoded NumPy array.
  
      Parameters
      ------------
      X : list of lists
        A python list of lists, where the outer list stores the
        n transactions and the inner list stores the items in each
        transaction.
  
        For example,
        [['Apple', 'Beer', 'Rice', 'Chicken'],
         ['Apple', 'Beer', 'Rice'],
         ['Apple', 'Beer'],
         ['Apple', 'Bananas'],
         ['Milk', 'Beer', 'Rice', 'Chicken'],
         ['Milk', 'Beer', 'Rice'],
         ['Milk', 'Beer'],
         ['Apple', 'Bananas']]
  
      sparse: bool (default=False)
        If True, transform will return Compressed Sparse Row matrix
        instead of the regular one.
  
      Returns
      ------------
      array : NumPy array [n_transactions, n_unique_items]
         if sparse=False (default).
         Compressed Sparse Row matrix otherwise
         The one-hot encoded boolean array of the input transactions,
         where the columns represent the unique items found in the input
         array in alphabetic order. Exact representation depends
         on the sparse argument
  
         For example,
         array([[True , False, True , True , False, True ],
                [True , False, True , False, False, True ],
                [True , False, True , False, False, False],
                [True , True , False, False, False, False],
                [False, False, True , True , True , True ],
                [False, False, True , False, True , True ],
                [False, False, True , False, True , False],
                [True , True , False, False, False, False]])
        The corresponding column labels are available as self.columns_, e.g.,
        ['Apple', 'Bananas', 'Beer', 'Chicken', 'Milk', 'Rice']
      """
      if sparse:
          indptr = [0]
          indices = []
          for transaction in X:
              # set is necessary because conversion to SparseDataFrame
              # will fail if there are duplicate items
              for item in set(transaction):
                  col_idx = self.columns_mapping_[item]
                  indices.append(col_idx)
              indptr.append(len(indices))
          non_sparse_values = [True] * len(indices)
          array = csr_matrix(
              (non_sparse_values, indices, indptr), dtype=bool
          )
      else:
          array = np.zeros((len(X), len(self.columns_)), dtype=bool)
          for row_idx, transaction in enumerate(X):
              for item in transaction:
                  col_idx = self.columns_mapping_[item]
                  array[row_idx, col_idx] = True
      return array
  
file_path: mlxtend/mlxtend/preprocessing/transactionencoder.py
imports: import numpy
  from scipy.sparse import csr_matrix
  from sklearn.base import BaseEstimator, TransformerMixin
label_desc: Use image node_id 3 for calling the TransactionEncoder obj's underlying member method code with example usage: obj.transform(X, sparse) and returns: array