code: def test_GPy(self):
      x_test_original = self.x_test.copy()
      # set up GPclassifier
      gpkern = GPy.kern.RBF(np.shape(self.x_train)[1])
      m = GPy.models.GPClassification(
          self.x_train, self.y_train.reshape(-1, 1), kernel=gpkern
      )
      m.inference_method = (
          GPy.inference.latent_function_inference.laplace.Laplace()
      )
      m.optimize(messages=True, optimizer="lbfgs")
      # get ART classifier + clean accuracy
      m_art = GPyGaussianProcessClassifier(m)
      clean_acc = np.mean(
          np.argmin(m_art.predict(self.x_test), axis=1) == self.y_test
      )
      # get adversarial examples, accuracy, and uncertainty
      attack = HighConfidenceLowUncertainty(
          m_art, conf=0.9, min_val=-0.0, max_val=1.0, verbose=False
      )
      adv = attack.generate(self.x_test)
      adv_acc = np.mean(
          np.argmin(m_art.predict(adv), axis=1) == self.y_test
      )
      unc_f = m_art.predict_uncertainty(adv)
      # not all attacks succeed due to the decision surface landscape of GP, some should
      self.assertGreater(clean_acc, adv_acc)
  
      # now take into account uncertainty
      attack = HighConfidenceLowUncertainty(
          m_art,
          unc_increase=0.9,
          conf=0.9,
          min_val=0.0,
          max_val=1.0,
          verbose=False,
      )
      adv = attack.generate(self.x_test)
      adv_acc = np.mean(
          np.argmin(m_art.predict(adv), axis=1) == self.y_test
      )
      unc_o = m_art.predict_uncertainty(adv)
      # same above
      self.assertGreater(clean_acc, adv_acc)
      # uncertainty should indeed be lower when used as a constraint
      # however, same as above, crafting might fail
      self.assertGreater(np.mean(unc_f > unc_o), 0.6)
  
      # Check that x_test has not been modified by attack and classifier
      self.assertAlmostEqual(
          float(np.max(np.abs(x_test_original - self.x_test))),
          0.0,
          delta=0.00001,
      )
  
file_path: adversarial-robustness-toolbox/tests/attacks/test_hclu.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import unittest
  import numpy
  import GPy
  from art.attacks.evasion.hclu import HighConfidenceLowUncertainty
  from art.estimators.classification.GPy import GPyGaussianProcessClassifier
  from tests.utils import TestBase
  from tests.attacks.utils import backend_test_classifier_type_check_fail
label_desc: Use image node_id 2 for calling the TestHCLU obj's underlying member method code with example usage: obj.test_GPy() without return types