docstr: Base class for categorical encoders.
  Args:
      cols (list): list of columns to encode, or None (then all dataset columns will be encoded at fitting time)
      handle_unseen (str):
          'error'  - raise an error if a category unseen at fitting time is found
          'ignore' - skip unseen categories
          'impute' - impute new categories to a predefined value, which is same as NAN_CATEGORY
      min_samples (int): minimum samples to take category as valid
      imputed (float): value to impute unseen categories
      handle_missing (str):
          'error'  - raise an error if missing values are found in columns to encode
          'impute' - impute missing values to a predefined value, which is same as NAN_CATEGORY
docstr_tok: ["Base","class","for","categorical","encoders",".","Args",":","cols","(","list",")",":","list","of","columns","to","encode",",","or","None","(","then","all","dataset","columns","will","be","encoded","at","fitting","time",")","handle_unseen","(","str",")",":","'error","'","-","raise","an","error","if","a","category","unseen","at","fitting","time","is","found","'ignore","'","-","skip","unseen","categories","'impute","'","-","impute","new","categories","to","a","predefined","value",",","which","is","same","as","NAN_CATEGORY","min_samples","(","int",")",":","minimum","samples","to","take","category","as","valid","imputed","(","float",")",":","value","to","impute","unseen","categories","handle_missing","(","str",")",":","'error","'","-","raise","an","error","if","missing","values","are","found","in","columns","to","encode","'impute","'","-","impute","missing","values","to","a","predefined","value",",","which","is","same","as","NAN_CATEGORY"]
code: def __init__(
      self, cols, handle_unseen, min_samples, imputed, handle_missing
  ):
      """Base class for categorical encoders.
      Args:
          cols (list): list of columns to encode, or None (then all dataset columns will be encoded at fitting time)
          handle_unseen (str):
              'error'  - raise an error if a category unseen at fitting time is found
              'ignore' - skip unseen categories
              'impute' - impute new categories to a predefined value, which is same as NAN_CATEGORY
          min_samples (int): minimum samples to take category as valid
          imputed (float): value to impute unseen categories
          handle_missing (str):
              'error'  - raise an error if missing values are found in columns to encode
              'impute' - impute missing values to a predefined value, which is same as NAN_CATEGORY
      """
      self.cols = cols
      self.handle_unseen = handle_unseen
      self.handle_missing = handle_missing
      self.min_samples = max(1, min_samples)
      # In case of unseen value or not enough data to learn the mapping, we use this value for imputation
      self._imputed = imputed
      # dict {str: pandas.DataFrame} column name --> mapping from category (index of df) to value (column of df)
      self._mapping = {}
  
imports: from pandas import DataFrame, Series, unique
  import numpy
  from rich.progress import track
  from sklearn.base import BaseEstimator, TransformerMixin
  from pytorch_tabular.utils import get_logger
label_desc: Use image node_id 1 to create a new BaseEncoder object  with example: obj = BaseEncoder(cols, handle_unseen, min_samples, imputed, handle_missing)