class_docstr: Close implementation of poisoning attack on Support Vector Machines (SVM) by Biggio et al.
  
  | Paper link: https://arxiv.org/pdf/1206.6389.pdf
class_docstr_tok: ["Close","implementation","of","poisoning","attack","on","Support","Vector","Machines","(","SVM",")","by","Biggio","et","al",".","|","Paper","link",":","https",":","\/\/arxiv.org\/pdf\/1206.6389.pdf"]
docstr: Initialize an SVM poisoning attack.
  
  :param classifier: A trained :class:`.ScikitlearnSVC` classifier.
  :param step: The step size of the classifier.
  :param eps: The minimum difference in loss before convergence of the classifier.
  :param x_train: The training data used for classification.
  :param y_train: The training labels used for classification.
  :param x_val: The validation data used to test the attack.
  :param y_val: The validation labels used to test the attack.
  :param max_iter: The maximum number of iterations for the attack.
  :raises `NotImplementedError`, `TypeError`: If the argument classifier has the wrong type.
  :param verbose: Show progress bars.
docstr_tok: ["Initialize","an","SVM","poisoning","attack",".",":","param","classifier",":","A","trained",":","class",":","`",".ScikitlearnSVC","`","classifier",".",":","param","step",":","The","step","size","of","the","classifier",".",":","param","eps",":","The","minimum","difference","in","loss","before","convergence","of","the","classifier",".",":","param","x_train",":","The","training","data","used","for","classification",".",":","param","y_train",":","The","training","labels","used","for","classification",".",":","param","x_val",":","The","validation","data","used","to","test","the","attack",".",":","param","y_val",":","The","validation","labels","used","to","test","the","attack",".",":","param","max_iter",":","The","maximum","number","of","iterations","for","the","attack",".",":","raises","`","NotImplementedError","`",",","`","TypeError","`",":","If","the","argument","classifier","has","the","wrong","type",".",":","param","verbose",":","Show","progress","bars","."]
code: def __init__(
      self,
      classifier: "ScikitlearnSVC",
      step: float,
      eps: float,
      x_train: np.ndarray,
      y_train: np.ndarray,
      x_val: np.ndarray,
      y_val: np.ndarray,
      max_iter: int,
      verbose: bool = True,
  ) -> None:
      """
      Initialize an SVM poisoning attack.
  
      :param classifier: A trained :class:`.ScikitlearnSVC` classifier.
      :param step: The step size of the classifier.
      :param eps: The minimum difference in loss before convergence of the classifier.
      :param x_train: The training data used for classification.
      :param y_train: The training labels used for classification.
      :param x_val: The validation data used to test the attack.
      :param y_val: The validation labels used to test the attack.
      :param max_iter: The maximum number of iterations for the attack.
      :raises `NotImplementedError`, `TypeError`: If the argument classifier has the wrong type.
      :param verbose: Show progress bars.
      """
      # pylint: disable=W0212
      from sklearn.svm import LinearSVC, SVC
  
      super().__init__(classifier=classifier)
  
      if isinstance(self.estimator.model, LinearSVC):
          self._estimator = ScikitlearnSVC(
              model=SVC(C=self.estimator.model.C, kernel="linear"),
              clip_values=self.estimator.clip_values,
          )
          self.estimator.fit(x_train, y_train)
      elif not isinstance(self.estimator.model, SVC):
          raise NotImplementedError(
              f"Model type '{type(self.estimator.model)}' not yet supported"
          )
  
      self.step = step
      self.eps = eps
      self.x_train = x_train
      self.y_train = y_train
      self.x_val = x_val
      self.y_val = y_val
      self.max_iter = max_iter
      self.verbose = verbose
      self._check_params()
  
file_path: adversarial-robustness-toolbox/art/attacks/poisoning/poisoning_attack_svm.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from typing import Optional, Tuple
  import numpy
  from tqdm.auto import tqdm
  from art.attacks.attack import PoisoningAttackWhiteBox
  from art.estimators.classification.scikitlearn import ScikitlearnSVC
  from art.utils import compute_success
label_desc: Use image node_id 1 to create a new PoisoningAttackSVM object from inherited base classes: PoisoningAttackWhiteBox with example: obj = PoisoningAttackSVM(classifier, step, eps, x_train, y_train, x_val, y_val, max_iter, verbose)