class_docstr: Base class for various contrast encoders
  
  Parameters
  ----------
  
  verbose: int
      integer indicating verbosity of the output. 0 for none.
  cols: list
      a list of columns to encode, if None, all string columns will be encoded.
  drop_invariant: bool
      boolean for whether or not to drop columns with 0 variance.
  return_df: bool
      boolean for whether to return a pandas DataFrame from transform (otherwise it will be a numpy array).
  handle_unknown: str
      options are 'error', 'return_nan', 'value', and 'indicator'. The default is 'value'. Warning: if indicator is used,
      an extra column will be added in if the transform matrix has unknown categories.  This can cause
      unexpected changes in dimension in some cases.
  handle_missing: str
      options are 'error', 'return_nan', 'value', and 'indicator'. The default is 'value'. Warning: if indicator is used,
      an extra column will be added in if the transform matrix has nan values.  This can cause
      unexpected changes in dimension in some cases.
  
  References
  ----------
  
  .. [1] Contrast Coding Systems for Categorical Variables, from
  https://stats.idre.ucla.edu/r/library/r-library-contrast-coding-systems-for-categorical-variables/
  
  .. [2] Gregory Carey (2003). Coding Categorical Variables, from
  http://ibgwww.colorado.edu/~carey/p5741ndir/Coding_Categorical_Variables.pdf
code: def fit_contrast_coding(
      self, col, values, handle_missing, handle_unknown
  ):
      if handle_missing == "value":
          values = values[values > 0]
  
      values_to_encode = values.to_numpy()
  
      if len(values) < 2:
          return pd.DataFrame(index=values_to_encode)
  
      if handle_unknown == "indicator":
          values_to_encode = np.append(values_to_encode, -1)
  
      contrast_matrix = self.get_contrast_matrix(values_to_encode)
      df = pd.DataFrame(
          data=contrast_matrix.matrix,
          index=values_to_encode,
          columns=[
              f"{col}_{i}"
              for i in range(len(contrast_matrix.column_suffixes))
          ],
      )
  
      if handle_unknown == "return_nan":
          df.loc[-1] = np.nan
      elif handle_unknown == "value":
          df.loc[-1] = np.zeros(len(values_to_encode) - 1)
  
      if handle_missing == "return_nan":
          df.loc[values.loc[np.nan]] = np.nan
      elif handle_missing == "value":
          df.loc[-2] = np.zeros(len(values_to_encode) - 1)
  
      return df
  
file_path: category_encoders/category_encoders/base_contrast_encoder.py
imports: from abc import abstractmethod
  import pandas
  from patsy.contrasts import ContrastMatrix
  import numpy
  from category_encoders.ordinal import OrdinalEncoder
  import category_encoders.utils
  import warnings
label_desc: Use image node_id 5 for calling the BaseContrastEncoder obj's underlying member method code with example usage: obj.fit_contrast_coding(col, values, handle_missing, handle_unknown) and returns: df, pd