class_docstr: AEEmbedding is an implementation of BaseEmbedding. AEEmbedding implements
  encoder-decoder architecture. This implementation is used by the NNContrastive
  explainer, to derive low-dimensional vector embedding in an unsupervised fashion.
class_docstr_tok: ["AEEmbedding","is","an","implementation","of","BaseEmbedding",".","AEEmbedding","implements","encoder-decoder","architecture",".","This","implementation","is","used","by","the","NNContrastive","explainer",",","to","derive","low-dimensional","vector","embedding","in","an","unsupervised","fashion","."]
code: def preprocess(
      self,
      x: Union[pd.DataFrame, np.ndarray],
      fit: bool = False,
  ):
      if isinstance(x, np.ndarray):
          assert (x.shape[-1] == len(self._features)) and (
              len(x.shape) == 2
          ), f"Error: expects data of shape (#, {len(self._features)})"
          x = pd.DataFrame(x, columns=self._features)
  
      assert isinstance(x, pd.DataFrame)
      x = x[self._features]
  
      cat_enc = self._config.get("category_encoding", "ohe")
      num_enc = self._config.get("numeric_scaling", "standard")
  
      if (not fit) and (not self.is_fitted):
          raise RuntimeError(
              f"Error: incorrect fit state for preprocessing!"
          )
  
      if fit is True:
          processors = []
          for i, feat in enumerate(self._features):
              if feat in self._categorical_features:
                  if cat_enc == "ohe":
                      processors.append(
                          OneHotEncoder(handle_unknown="ignore")
                      )
                  else:
                      processors.append(
                          OrdinalEncoder(
                              handle_unknown="use_encoded_value"
                          )
                      )
              else:
                  if num_enc == "standard":
                      processors.append(StandardScaler())
                  elif num_enc == "minmax":
                      processors.append(MinMaxScaler())
                  elif num_enc == "quantile":
                      processors.append(QuantileTransformer())
                  else:
                      processors.append(None)
          self._config["processors"] = processors
      else:
          processors = self._config.get("processors")
  
      x = x.values
      xx = []
      for i, feat in enumerate(self._features):
          if fit is True:
              if processors[i] is None:
                  xi = x[:, i][..., np.newaxis]
              elif isinstance(processors[i], OneHotEncoder):
                  xi = (
                      processors[i]
                      .fit_transform(x[:, i][..., np.newaxis])
                      .todense()
                  )
              else:
                  xi = processors[i].fit_transform(
                      x[:, i][..., np.newaxis]
                  )
          else:
              if processors[i] is None:
                  xi = x[:, i][..., np.newaxis]
              elif isinstance(processors[i], OneHotEncoder):
                  xi = (
                      processors[i]
                      .transform(x[:, i][..., np.newaxis])
                      .todense()
                  )
              else:
                  xi = processors[i].transform(x[:, i][..., np.newaxis])
          xx.append(xi)
  
      x = np.concatenate(xx, axis=1).astype("float32")
      return x
  
imports: import numpy
  import pandas
  from abc import ABC, abstractmethod
  from typing import Union, List, Any
  from sklearn.preprocessing import OneHotEncoder, OrdinalEncoder, QuantileTransformer, StandardScaler, MinMaxScaler
label_desc: Use image node_id 2 for calling the AEEmbedding obj's underlying member method code with example usage: obj.preprocess(x, fit) and returns: x