class_docstr: Wrapper for running a grid search over threshold, margin combinations for
  a RejectOptionClassifier.
  
  Note:
      :class:`~sklearn.model_selection.GridSearchCV` does not currently
      support sample weights in scoring. This will work but throw a warning if
      `sample_weight` is provided.
  
  See also:
      :class:`RejectOptionClassifier`
  
  Examples:
      >>> import matplotlib.pyplot as plt
      >>> import pandas as pd
      >>> from sklearn.linear_model import LogisticRegression
      >>> from aif360.sklearn.datasets import fetch_german
      >>> from aif360.sklearn.postprocessing import RejectOptionClassifierCV
      >>> X, y = fetch_german(numeric_only=True)
      >>> lr = LogisticRegression(solver='lbfgs').fit(X, y)
      >>> roc = RejectOptionClassifierCV('sex', scoring='disparate_impact')
      >>> roc.fit(pd.DataFrame(lr.predict_proba(X), index=X.index), y)
  
      We can also achieve this more simply using a PostProcessingMeta
      estimator:
  
      >>> from aif360.sklearn.postprocessing import PostProcessingMeta
      >>> pp = PostProcessingMeta(lr, roc).fit(X, y)
docstr: Args:
      prot_attr (single label or list-like, optional): Protected
          attribute(s) to use in the post-processing. If more than one
          attribute, all combinations of values (intersections) are
          considered. Default is ``None`` meaning all protected attributes
          from the dataset are used. Note: This algorithm requires there
          be exactly 2 groups (privileged and unprivileged).
      scoring ('statistical_parity', 'average_odds', 'equal_opportunity',
          'disparate_impact', or callable/dict): Fairness scorer to use to
          evaluate the predictions. If type is a `str`, constructs the
          corresponding scorer for that metric in addition to the default
          balanced accuracy. If type is callable (i.e., a scorer object),
          that will be used along with balanced accuracy. Finally, if an
          explicit dictionary is passed, this will be used as is.
      step (float): Step size for grid search. Will search every valid
          combination of threshold and margin that are multiples of this
          step size. See `param_grid` after fitting for the exact search
          space.
      refit (bool or callable, optional): Refit the estimator using the
          best parameters found. If `True` and not using a custom scoring
          function, this chooses the highest balanced accuracy given
          fairness score > -0.1 (or > 0.8 for disparate impact only).
          Alternatively, a custom refitting function may be passed. See
          :class:`~sklearn.model_selection.GridSearchCV` for details.
      **kwargs: See :class:`~sklearn.model_selection.GridSearchCV` for
          additional kwargs.
docstr_tok: ["Args",":","prot_attr","(","single","label","or","list-like",",","optional",")",":","Protected","attribute","(","s",")","to","use","in","the","post-processing",".","If","more","than","one","attribute",",","all","combinations","of","values","(","intersections",")","are","considered",".","Default","is","``","None","``","meaning","all","protected","attributes","from","the","dataset","are","used",".","Note",":","This","algorithm","requires","there","be","exactly","2","groups","(","privileged","and","unprivileged",")",".","scoring","(","'statistical_parity","'",",","'average_odds","'",",","'equal_opportunity","'",",","'disparate_impact","'",",","or","callable\/dict",")",":","Fairness","scorer","to","use","to","evaluate","the","predictions",".","If","type","is","a","`","str","`",",","constructs","the","corresponding","scorer","for","that","metric","in","addition","to","the","default","balanced","accuracy",".","If","type","is","callable","(","i.e.",",","a","scorer","object",")",",","that","will","be","used","along","with","balanced","accuracy",".","Finally",",","if","an","explicit","dictionary","is","passed",",","this","will","be","used","as","is",".","step","(","float",")",":","Step","size","for","grid","search",".","Will","search","every","valid","combination","of","threshold","and","margin","that","are","multiples","of","this","step","size",".","See","`","param_grid","`","after","fitting","for","the","exact","search","space",".","refit","(","bool","or","callable",",","optional",")",":","Refit","the","estimator","using","the","best","parameters","found",".","If","`","True","`","and","not","using","a","custom","scoring","function",",","this","chooses","the","highest","balanced","accuracy","given","fairness","score",">","-0.1","(","or",">","0.8","for","disparate","impact","only",")",".","Alternatively",",","a","custom","refitting","function","may","be","passed",".","See",":","class",":","`","~sklearn.model_selection.GridSearchCV","`","for","details",".","*","*","kwargs",":","See",":","class",":","`","~sklearn.model_selection.GridSearchCV","`","for","additional","kwargs","."]
code: def __init__(
      self, prot_attr=None, *, scoring, step=0.05, refit=True, **kwargs
  ):
      """
      Args:
          prot_attr (single label or list-like, optional): Protected
              attribute(s) to use in the post-processing. If more than one
              attribute, all combinations of values (intersections) are
              considered. Default is ``None`` meaning all protected attributes
              from the dataset are used. Note: This algorithm requires there
              be exactly 2 groups (privileged and unprivileged).
          scoring ('statistical_parity', 'average_odds', 'equal_opportunity',
              'disparate_impact', or callable/dict): Fairness scorer to use to
              evaluate the predictions. If type is a `str`, constructs the
              corresponding scorer for that metric in addition to the default
              balanced accuracy. If type is callable (i.e., a scorer object),
              that will be used along with balanced accuracy. Finally, if an
              explicit dictionary is passed, this will be used as is.
          step (float): Step size for grid search. Will search every valid
              combination of threshold and margin that are multiples of this
              step size. See `param_grid` after fitting for the exact search
              space.
          refit (bool or callable, optional): Refit the estimator using the
              best parameters found. If `True` and not using a custom scoring
              function, this chooses the highest balanced accuracy given
              fairness score > -0.1 (or > 0.8 for disparate impact only).
              Alternatively, a custom refitting function may be passed. See
              :class:`~sklearn.model_selection.GridSearchCV` for details.
          **kwargs: See :class:`~sklearn.model_selection.GridSearchCV` for
              additional kwargs.
      """
      self.scoring = scoring
      self.refit = refit
      self.step = step
      self.prot_attr = prot_attr
      super().__init__(
          RejectOptionClassifier(),
          {},
          scoring=scoring,
          refit=refit,
          **kwargs,
      )
  
imports: import warnings
  import numpy
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.model_selection import GridSearchCV
  from sklearn.utils.validation import check_is_fitted
  from aif360.sklearn.metrics import statistical_parity_difference
  from aif360.sklearn.metrics import average_odds_error
  from aif360.sklearn.metrics import equal_opportunity_difference
  from aif360.sklearn.metrics import disparate_impact_ratio
  from aif360.sklearn.metrics import make_scorer
  from aif360.sklearn.utils import check_groups
label_desc: Use image node_id 1 to create a new RejectOptionClassifierCV object from inherited base classes: GridSearchCV with example: obj = RejectOptionClassifierCV(prot_attr)