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: Compute the threshold based on the given threshold_type and threshold_value.
  
  Parameters
  ----------
  X : pd.DataFrame
      The input data.
  y_hat : pd.Series
      The pre-transformed predictions.
  y : pd.Series
      The target values.
  s : pd.Series, optional
      The protected attribute.
code: def fit(
      self,
      X: pd.DataFrame,
      y_hat: pd.Series,
      y: pd.Series,
      s: Optional[pd.Series] = None,
  ) -> None:
      """Compute the threshold based on the given threshold_type and threshold_value.
  
      Parameters
      ----------
      X : pd.DataFrame
          The input data.
      y_hat : pd.Series
          The pre-transformed predictions.
      y : pd.Series
          The target values.
      s : pd.Series, optional
          The protected attribute.
      """
      self.logger.info("Computing threshold.")
  
      if self.threshold_type in [
          "fixed",
          "top_pct",
          "top_k",
      ]:  # Fitted in transformation step
          pass
  
      elif self.threshold_type == "fpr":
          ln_scores = np.array(y_hat[y == 0].values)
          self.threshold = np.percentile(
              ln_scores, 1 - self.threshold_value
          )
          self.logger.debug(f"Threshold of value {self.threshold}")
  
      elif self.threshold_type == "tpr":
          lp_scores = np.array(y_hat[y == 1].values)
          self.threshold = np.percentile(
              lp_scores, 1 - self.threshold_value
          )
          self.logger.debug(f"Threshold of value {self.threshold}")
  
      self.logger.info("Finished computing threshold.")
  
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 2 for calling the Threshold obj's underlying member method code with example usage: obj.fit(X, y_hat, y, s) without return types