class_docstr: Reader class for reading data with different types of format.
  
  Parameters
  ----------
  user_set: set, default = None
      Set of users to be retained when reading data.
      If `None`, all users will be included.
  
  item_set: set, default = None
      Set of items to be retained when reading data.
      If `None`, all items will be included.
  
  min_user_freq: int, default = 1
      The minimum frequency of a user to be retained.
      If `min_user_freq = 1`, all users will be included.
  
  min_item_freq: int, default = 1
      The minimum frequency of an item to be retained.
      If `min_item_freq = 1`, all items will be included.
  
  num_top_freq_user: int, default = 0
      The number of top popular users to be retained.
      If `num_top_freq_user = 0`, all users will be included.
  
  num_top_freq_item: int, default = 0
      The number of top popular items to be retained.
      If `num_top_freq_item = 0`, all items will be included.
  
  min_basket_size: int, default = 1
      The minimum number of items of a basket to be retained.
      If `min_basket_size = 1`, all items will be included.
  
  max_basket_size: int, default = -1
      The maximum number of items of a basket to be retained.
      If `min_basket_size = -1`, all items will be included.
  
  min_basket_sequence: int, default = 1
      The minimum number of baskets of a user to be retained.
      If `min_basket_sequence = 1`, all baskets will be included.
  
  min_sequence_size: int, default = 1
      The minimum number of items of a sequence to be retained.
      If `min_sequence_size = 1`, all sequences will be included.
  
  max_sequence_size: int, default = -1
      The maximum number of items of a sequence to be retained.
      If `min_sequence_size = -1`, all sequences will be included.
  
  bin_threshold: float, default = None
      The rating threshold to binarize rating values (turn explicit feedback to implicit feedback).
      For example, if `bin_threshold = 3.0`, all rating values >= 3.0 will be set to 1.0,
      and the rest (< 3.0) will be discarded.
  
  encoding: str, default = `utf-8`
      Encoding used to decode the file.
  
  errors: int, default = None
      Optional string that specifies how encoding errors are to be handled.
      Pass 'strict' to raise a ValueError exception if there is an encoding error
      (None has the same effect), or pass 'ignore' to ignore errors.
code: def _filter_basket(self, tuples, fmt="UBI"):
      u_pos = fmt.find("U")
      b_pos = fmt.find("B")
  
      if self.min_basket_size > 1:
          sizes = Counter(t[b_pos] for t in tuples)
          tuples = [
              t
              for t in tuples
              if sizes[t[b_pos]] >= self.min_basket_size
          ]
  
      if self.max_basket_size > 1:
          sizes = Counter(t[b_pos] for t in tuples)
          tuples = [
              t
              for t in tuples
              if sizes[t[b_pos]] <= self.max_basket_size
          ]
  
      if self.min_basket_sequence > 1:
          basket_sequence = Counter(
              u for (u, _) in set((t[u_pos], t[b_pos]) for t in tuples)
          )
          tuples = [
              t
              for t in tuples
              if basket_sequence[t[u_pos]] >= self.min_basket_sequence
          ]
  
      return tuples
  
imports: import ast
  import itertools
  from collections import Counter
label_desc: Use image node_id 3 for calling the Reader obj's underlying member method code with example usage: obj._filter_basket(tuples, fmt) and returns: tuples