class_docstr: A unittest class for testing Poisoning Attack on SVMs.
class_docstr_tok: ["A","unittest","class","for","testing","Poisoning","Attack","on","SVMs","."]
docstr: First test with the TensorFlowClassifier.
  :return:
docstr_tok: ["First","test","with","the","TensorFlowClassifier",".",":","return",":"]
code: def test_SVC_kernels(self):
      """
      First test with the TensorFlowClassifier.
      :return:
      """
      # Get MNIST
      (x_train, y_train), (x_test, y_test), min_, max_ = self.iris
      x_test_original = x_test.copy()
  
      # Build Scikitlearn Classifier
      clip_values = (min_, max_)
      for kernel in ["linear"]:  # ["linear", "poly", "rbf"]
          clean = SklearnClassifier(
              model=SVC(kernel=kernel, gamma="auto"),
              clip_values=clip_values,
          )
          clean.fit(x_train, y_train)
          poison = SklearnClassifier(
              model=SVC(kernel=kernel, gamma="auto"),
              clip_values=clip_values,
          )
          poison.fit(x_train, y_train)
          attack = PoisoningAttackSVM(
              poison,
              step=0.01,
              eps=1.0,
              x_train=x_train,
              y_train=y_train,
              x_val=x_test,
              y_val=y_test,
              max_iter=100,
          )
          attack_y = np.array([1, 1]) - y_train[0]
          attack_point, _ = attack.poison(
              np.array([x_train[0]]), y=np.array([attack_y])
          )
          poison.fit(
              x=np.vstack([x_train, attack_point]),
              y=np.vstack(
                  [
                      y_train,
                      np.array([1, 1])
                      - np.copy(y_train[0].reshape((1, 2))),
                  ]
              ),
          )
  
          acc = (
              np.average(
                  np.all(clean.predict(x_test) == y_test, axis=1)
              )
              * 100
          )
          poison_acc = (
              np.average(
                  np.all(poison.predict(x_test) == y_test, axis=1)
              )
              * 100
          )
          logger.info("Clean Accuracy {}%".format(acc))
          logger.info("Poison Accuracy {}%".format(poison_acc))
          self.assertGreaterEqual(acc, poison_acc)
  
          # Check that x_test has not been modified by attack and classifier
          self.assertAlmostEqual(
              float(np.max(np.abs(x_test_original - x_test))),
              0.0,
              delta=0.00001,
          )
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  from sklearn.svm import NuSVC, SVC
  from art.attacks.poisoning import PoisoningAttackSVM
  from art.estimators.classification.scikitlearn import SklearnClassifier, ScikitlearnSVC
  from art.utils import load_iris
  from tests.utils import master_seed
  from tests.attacks.utils import backend_test_classifier_type_check_fail
label_desc: Use image node_id 7 for calling the TestSVMAttack obj's underlying member method code with example usage: obj.test_SVC_kernels() without return types