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: Initialize a new Threshold instance.
  
  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.
  
  Raises
  ------
  ValueError
      If an invalid threshold_type or threshold_value is provided.
code: def __init__(
      self, threshold_type: str, threshold_value: Union[float, int]
  ):
      """Initialize a new Threshold instance.
  
      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.
  
      Raises
      ------
      ValueError
          If an invalid threshold_type or threshold_value is provided.
      """
      self.logger = create_logger("methods.postprocessing.Threshold")
      self.logger.info("Instantiating postprocessing Threshold.")
      # Validate type
      if threshold_type not in THRESHOLD_TYPES:
          raise ValueError(
              f"Invalid threshold type. Select one of {THRESHOLD_TYPES}"
          )
      self.threshold_type = threshold_type
      # Validate value
      if (
          self.threshold_type in THRESHOLD_TYPES[:-1]
      ):  # Assuming THRESHOLD_TYPES
          if 0 <= threshold_value <= 1:
              pass
          else:
              raise ValueError(
                  "Invalid threshold value, must be between 0 and 1."
              )
      else:
          if not isinstance(threshold_type, int):
              raise ValueError(
                  "Invalid threshold type, must be integer for top_k."
              )
      self.threshold_value = threshold_value
      self.logger.debug(
          f"{self.threshold_type} Threshold with value {self.threshold_value}"
      )
  
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 1 to create a new Threshold object from inherited base classes: PostProcessing with example: obj = Threshold(threshold_type, threshold_value)