class_docstr: Close implementation based on description in Nelson
  'Behavior of Machine Learning Algorithms in Adversarial Environments' Ch. 4.4
  
  | Textbook link: https://people.eecs.berkeley.edu/~adj/publications/paper-files/EECS-2010-140.pdf
class_docstr_tok: ["Close","implementation","based","on","description","in","Nelson","'Behavior","of","Machine","Learning","Algorithms","in","Adversarial","Environments","'","Ch",".","4.4","|","Textbook","link",":","https",":","\/\/people.eecs.berkeley.edu\/~adj\/publications\/paper-files\/EECS-2010-140.pdf"]
docstr: Create an :class:`.RONIDefense` object with the provided classifier.
  
  :param classifier: Model evaluated for poison.
  :param x_train: Dataset used to train the classifier.
  :param y_train: Labels used to train the classifier.
  :param x_val: Trusted data points.
  :param y_train: Trusted data labels.
  :param perf_func: Performance function to use.
  :param pp_cal: Percent of training data used for calibration.
  :param pp_quiz: Percent of training data used for quiz set.
  :param calibrated: True if using the calibrated form of RONI.
  :param eps: performance threshold if using uncalibrated RONI.
docstr_tok: ["Create","an",":","class",":","`",".RONIDefense","`","object","with","the","provided","classifier",".",":","param","classifier",":","Model","evaluated","for","poison",".",":","param","x_train",":","Dataset","used","to","train","the","classifier",".",":","param","y_train",":","Labels","used","to","train","the","classifier",".",":","param","x_val",":","Trusted","data","points",".",":","param","y_train",":","Trusted","data","labels",".",":","param","perf_func",":","Performance","function","to","use",".",":","param","pp_cal",":","Percent","of","training","data","used","for","calibration",".",":","param","pp_quiz",":","Percent","of","training","data","used","for","quiz","set",".",":","param","calibrated",":","True","if","using","the","calibrated","form","of","RONI",".",":","param","eps",":","performance","threshold","if","using","uncalibrated","RONI","."]
code: def __init__(
      self,
      classifier: "CLASSIFIER_TYPE",
      x_train: np.ndarray,
      y_train: np.ndarray,
      x_val: np.ndarray,
      y_val: np.ndarray,
      perf_func: Union[str, Callable] = "accuracy",
      pp_cal: float = 0.2,
      pp_quiz: float = 0.2,
      calibrated: bool = True,
      eps: float = 0.1,
  ):
      """
      Create an :class:`.RONIDefense` object with the provided classifier.
  
      :param classifier: Model evaluated for poison.
      :param x_train: Dataset used to train the classifier.
      :param y_train: Labels used to train the classifier.
      :param x_val: Trusted data points.
      :param y_train: Trusted data labels.
      :param perf_func: Performance function to use.
      :param pp_cal: Percent of training data used for calibration.
      :param pp_quiz: Percent of training data used for quiz set.
      :param calibrated: True if using the calibrated form of RONI.
      :param eps: performance threshold if using uncalibrated RONI.
      """
      super().__init__(classifier, x_train, y_train)
      n_points = len(x_train)
      quiz_idx = np.random.randint(
          n_points, size=int(pp_quiz * n_points)
      )
      self.calibrated = calibrated
      self.x_quiz = np.copy(self.x_train[quiz_idx])
      self.y_quiz = np.copy(self.y_train[quiz_idx])
      if self.calibrated:
          _, self.x_cal, _, self.y_cal = train_test_split(
              self.x_train, self.y_train, test_size=pp_cal, shuffle=True
          )
      self.eps = eps
      self.evaluator = GroundTruthEvaluator()
      self.x_val = x_val
      self.y_val = y_val
      self.perf_func = perf_func
      self.is_clean_lst: List[int] = []
      self._check_params()
  
file_path: adversarial-robustness-toolbox/art/defences/detector/poison/roni.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from copy import deepcopy
  from typing import Callable, List, Tuple, Union, TYPE_CHECKING
  import numpy
  from sklearn.model_selection import train_test_split
  from art.defences.detector.poison.ground_truth_evaluator import GroundTruthEvaluator
  from art.defences.detector.poison.poison_filtering_defence import PoisonFilteringDefence
  from art.utils import performance_diff
label_desc: Use image node_id 1 to create a new RONIDefense object from inherited base classes: PoisonFilteringDefence with example: obj = RONIDefense(classifier, x_train, y_train, x_val, y_val, perf_func, pp_cal, pp_quiz, calibrated, eps)