docstr: Generates training sample with balanced prevalence for the groups in dataset.
  
  Parameters
  ----------
  s_ref : Any
      Reference group value. The global prevalence value will be obtained from
      this group. If None, the selected value will be the most frequent group.
      If "global", the reference prevalence will be calculated for the dataset.
  alpha : float, optional
      Parameter that controls the new prevalence values. A value of 0 keeps
      original prevalence, and a value of 1 equalizes the prevalence.
      Defaults to 1.
  strategy : string, optional
      Strategy of sampling. If "undersample", removes samples until reaching
      desired value. If "oversample", creates instead a bootstrap sample.
      Defaults to "undersample".
code: def __init__(
      self,
      s_ref: Optional[Any] = "global",
      alpha: float = 1,
      strategy: str = "undersample",
      seed: int = 42,
  ):
      """Generates training sample with balanced prevalence for the groups in dataset.
  
      Parameters
      ----------
      s_ref : Any
          Reference group value. The global prevalence value will be obtained from
          this group. If None, the selected value will be the most frequent group.
          If "global", the reference prevalence will be calculated for the dataset.
      alpha : float, optional
          Parameter that controls the new prevalence values. A value of 0 keeps
          original prevalence, and a value of 1 equalizes the prevalence.
          Defaults to 1.
      strategy : string, optional
          Strategy of sampling. If "undersample", removes samples until reaching
          desired value. If "oversample", creates instead a bootstrap sample.
          Defaults to "undersample".
      """
      self.logger = create_logger(
          "methods.preprocessing.PrevalenceSampling"
      )
      self.logger.info(
          "Instantiating a PrevalenceSampling preprocessing method."
      )
      # Validate sampling strategy:
      if strategy not in STRATEGIES:
          raise ValueError(
              f"Invalid strategy value. Try one of {STRATEGIES}."
          )
      self.strategy = strategy
      self.s_ref = s_ref
      self.alpha = alpha
      self.or_prevalence: dict[Any, float] = None  # type: ignore
      self.ref_prevalence: float = None  # type: ignore
      self.used_in_inference = False
      self.seed = seed
  
file_path: aequitas/src/aequitas/fairflow/methods/preprocessing/prevalence_sample.py
imports: from typing import Any, Optional
  import pandas
  from ...utils import create_logger
  from .preprocessing import PreProcessing
label_desc: Use image node_id 1 to create a new PrevalenceSampling object from inherited base classes: PreProcessing with example: obj = PrevalenceSampling(s_ref, alpha, strategy, seed)