code: def roc_pivot(
      explainer,
      protected,
      privileged,
      cutoff=0.5,
      theta=0.05,
      verbose=True,
  ):
      """Reject Option based Classification pivot
  
      Reject Option based Classifier is post-processing bias
      mitigation method. Method changes the predictions of model
      (probabilities) and returns new explainer with modified 'y_hat'.
      Probabilities that are made for privileged subgroup and are
      favorable, and close to cutoff are pivoted to the other side
      of the cutoff. The opposite happens for unprivileged observations
      (changing unfavorable and close to cutoff observations to favorable
      by pivoting probabilities from left of the cutoff to right).
      By this potentially wrongfully labeled observations are
      assigned different labels. Note that 1 in y in Explainer
      should indicate favorable outcome.
  
      Parameters
      -----------
      explainer: Explainer
          Explainer made from classification model.
  
      protected : np.ndarray (1d)
          Vector, preferably 1-dimensional np.ndarray containing strings,
          which denotes the membership to a subgroup.
          NOTE: List and pd.Series are also supported; however, if provided,
          they will be transformed into a np.ndarray (1d) with dtype 'U'.
      privileged : str
          Subgroup that is suspected to have the most privilege.
          It needs to be a string present in `protected`.
      cutoff: float
          Threshold for probabilistic output of a classifier.
      theta: float
          Value that indicates the radius of the area where values
          are pivoted. The default is (0.05) which means that
          the probabilities of privileged class within
          (cutoff, cutoff+ theta)  will be pivoted to the other
          side of the cutoff. The opposite thing will happen for
          unprivileged subgroup.
      verbose : bool
          Print messages about changes of types in 'y' and 'protected' (default is `True`).
  
      Returns
      -----------
      Explainer class object
          Explainer with changed 'y_hat'
  
      Notes
      -----------
      - https://ieeexplore.ieee.org/document/6413831/
      """
  
      if not isinstance(explainer, dalex.Explainer):
          raise ParameterCheckError(
              "explainer must be of type 'Explainer'"
          )
  
      if explainer.model_type != "classification":
          raise ParameterCheckError(
              "model in explainer must be binary classification type"
          )
  
      # same checking as in epsilon
      theta = checks.check_epsilon(theta, "theta")
      cutoff = checks.check_epsilon(cutoff, "cutoff")
  
      protected = basic_checks.check_protected(protected, verbose)
      privileged = basic_checks.check_privileged(
          privileged, protected, verbose
      )
  
      exp = copy.deepcopy(explainer)
      probs = exp.y_hat
  
      if not len(probs) == len(protected):
          raise ParameterCheckError(
              "protected and target (y) must have the same length"
          )
  
      is_close = np.abs(probs - cutoff) < theta
      is_privileged = privileged == protected
      is_favorable = probs > cutoff
  
      probs[is_close & is_privileged & is_favorable] = cutoff - (
          probs[is_close & is_privileged & is_favorable] - cutoff
      )
      probs[
          is_close
          & np.logical_not(is_privileged)
          & np.logical_not(is_favorable)
      ] = cutoff + (
          cutoff
          - probs[
              is_close
              & np.logical_not(is_privileged)
              & np.logical_not(is_favorable)
          ]
      )
  
      probs[probs < 0] = 0
      probs[probs > 1] = 1
  
      return exp
  
file_path: DALEX/python/dalex/dalex/fairness/_group_fairness/mitigation.py
imports: import copy
  import numpy
  import dalex.datasets
  from .None import checks
  from .._basics import checks
  from .._basics.exceptions import ParameterCheckError
  from ..._explainer import helper
label_desc: Use image node_id 2 for calling a global function with example usage: roc_pivot(explainer, protected, privileged, cutoff, theta, verbose) and returns: exp