class_docstr: A postprocessing class that applies thresholding to the model's predictions.
  
  Parameters
  ----------
  threshold_type : str
      Type of threshold to apply to the model's predictions. Must be one of:
      'fixed', 'fpr', 'tpr', 'top_pct', 'top_k'.
  threshold_value : Union[float, int]
      Threshold value to apply. The meaning of the threshold value depends on
      the threshold_type. Must be between 0 and 1 for 'fixed', 'fpr', and
      'tpr' threshold types. Must be an integer for 'top_k' threshold type.
  
  Methods
  -------
  fit(X, y_hat, y, s=None)
      Compute the threshold based on the given threshold_type and threshold_value.
docstr: Transform predicted scores using threshold.
  
  Parameters
  ----------
  X : numpy.ndarray
      The input data.
  y_hat : pandas.Series
      The pre-transformed predictions.
  s : pandas.Series, optional
      The protected attribute.
  
  Returns
  -------
  pd.Series
      Transformed predicted scores.
code: def transform(
      self,
      X: pd.DataFrame,
      y_hat: pd.Series,
      s: Optional[pd.Series] = None,
  ) -> pd.Series:
      """Transform predicted scores using threshold.
  
      Parameters
      ----------
      X : numpy.ndarray
          The input data.
      y_hat : pandas.Series
          The pre-transformed predictions.
      s : pandas.Series, optional
          The protected attribute.
  
      Returns
      -------
      pd.Series
          Transformed predicted scores.
      """
      self.logger.info("Transforming predictions.")
  
      if self.threshold_type == "fixed":
          y_pred = (y_hat >= self.threshold_value).astype(int)
      elif self.threshold_type in ["fpr", "tpr"]:
          y_pred = (y_hat >= self.threshold).astype(int)
      elif self.threshold_type == "top_pct":
          n_top = int(len(y_hat) * self.threshold_value)
          y_pred = (y_hat >= y_hat.nlargest(n_top).min()).astype(int)
      elif self.threshold_type == "top_k":
          if self.threshold_value is not int:
              raise ValueError(
                  f"Invalid threshold value for top_k. Must be integer, got "
                  f"{type(self.threshold_value)}"
              )
          y_pred = (
              y_hat >= y_hat.nlargest(self.threshold_value).min()
          ).astype(int)
      else:
          raise ValueError(
              f"Invalid threshold type: {self.threshold_type}"
          )
      self.logger.info("Finished transforming predictions.")
      return y_pred
  
file_path: aequitas/src/aequitas/fairflow/methods/postprocessing/threshold.py
imports: from typing import Optional, Union
  import numpy
  import pandas
  from ...utils import create_logger
  from .postprocessing import PostProcessing
label_desc: Use image node_id 3 for calling the Threshold obj's underlying member method code with example usage: obj.transform(X, y_hat, s) and returns: y_pred