class_docstr: Class defining ordinal distribution type functionality
docstr: Ordinal Transforms the data.
  Calculates the log cumulative odds of the original distribution.
  
  **WARN** This preprocessing CANNOT reorder the columns of X.
  
  Args:
      X: The original passed-in data.
  
      fit_transform: Whether the class first fits
      then transforms the data, or just transforms.
      Just transforming is used to preprocess new data after the
      initial NOTEARS fit.
  
  Returns:
      Preprocessed X
code: def preprocess_X(
      self, X: np.ndarray, fit_transform: bool = True
  ) -> np.ndarray:
      """
      Ordinal Transforms the data.
      Calculates the log cumulative odds of the original distribution.
  
      **WARN** This preprocessing CANNOT reorder the columns of X.
  
      Args:
          X: The original passed-in data.
  
          fit_transform: Whether the class first fits
          then transforms the data, or just transforms.
          Just transforming is used to preprocess new data after the
          initial NOTEARS fit.
  
      Returns:
          Preprocessed X
      """
  
      # deepcopy to prevent overwrite errors
      X = deepcopy(X)
  
      # fit the OrdinalEncoder
      if fit_transform:
          self.encoder = OrdinalEncoder()
          self.encoder.fit(X[:, [self.idx]])
  
      # Ordinal Encoder
      X[:, [self.idx]] = self.encoder.transform(X[:, [self.idx]])
  
      # only calc log_cum_odds on fit step
      if fit_transform:
          # calculate the cumulative probability across each category
          _, counts_elements = np.unique(
              X[:, self.idx], return_counts=True
          )
          class_probs = counts_elements / np.sum(counts_elements)
          cum_class_probs = np.cumsum(class_probs)
          # last value is guaranteed to be 1.0 so remove to prevent divide by zero
          cum_class_probs = cum_class_probs[:-1]
  
          # store the log cumulative odds across all categories
          self.log_cum_odds = np.log(
              cum_class_probs / (1 - cum_class_probs)
          )
  
      return X
  
file_path: causalnex/causalnex/structure/pytorch/dist_type/ordinal.py
imports: from copy import deepcopy
  import numpy
  import torch
  from sklearn.preprocessing import OrdinalEncoder
  from causalnex.structure.pytorch.dist_type._base import DistTypeBase
label_desc: Use image node_id 1 for calling the DistTypeOrdinal obj's underlying member method code with example usage: obj.preprocess_X(X, fit_transform) and returns: X