class_docstr: Method from Chen et al., 2018 performing poisoning detection based on activations clustering.
  
  | Paper link: https://arxiv.org/abs/1811.03728
  
  | Please keep in mind the limitations of defences. For more information on the limitations of this
      defence, see https://arxiv.org/abs/1905.13409 . For details on how to evaluate classifier security
      in general, see https://arxiv.org/abs/1902.06705
docstr: Create an :class:`.ActivationDefence` object with the provided classifier.
  
  :param classifier: Model evaluated for poison.
  :param x_train: A dataset used to train the classifier.
  :param y_train: Labels used to train the classifier.
  :param generator: A data generator to be used instead of `x_train` and `y_train`.
  :param ex_re_threshold: Set to a positive value to enable exclusionary reclassification
docstr_tok: ["Create","an",":","class",":","`",".ActivationDefence","`","object","with","the","provided","classifier",".",":","param","classifier",":","Model","evaluated","for","poison",".",":","param","x_train",":","A","dataset","used","to","train","the","classifier",".",":","param","y_train",":","Labels","used","to","train","the","classifier",".",":","param","generator",":","A","data","generator","to","be","used","instead","of","`","x_train","`","and","`","y_train","`",".",":","param","ex_re_threshold",":","Set","to","a","positive","value","to","enable","exclusionary","reclassification"]
code: def __init__(
      self,
      classifier: "CLASSIFIER_NEURALNETWORK_TYPE",
      x_train: np.ndarray,
      y_train: np.ndarray,
      generator: Optional[DataGenerator] = None,
      ex_re_threshold: Optional[float] = None,
  ) -> None:
      """
      Create an :class:`.ActivationDefence` object with the provided classifier.
  
      :param classifier: Model evaluated for poison.
      :param x_train: A dataset used to train the classifier.
      :param y_train: Labels used to train the classifier.
      :param generator: A data generator to be used instead of `x_train` and `y_train`.
      :param ex_re_threshold: Set to a positive value to enable exclusionary reclassification
      """
      super().__init__(classifier, x_train, y_train)
      self.classifier: "CLASSIFIER_NEURALNETWORK_TYPE" = classifier
      self.nb_clusters = 2
      self.clustering_method = "KMeans"
      self.nb_dims = 10
      self.reduce = "PCA"
      self.cluster_analysis = "smaller"
      self.generator = generator
      self.activations_by_class: List[np.ndarray] = []
      self.clusters_by_class: List[np.ndarray] = []
      self.assigned_clean_by_class: np.ndarray
      self.is_clean_by_class: List[np.ndarray] = []
      self.errors_by_class: np.ndarray
      self.red_activations_by_class: List[
          np.ndarray
      ] = []  # Activations reduced by class
      self.evaluator = GroundTruthEvaluator()
      self.is_clean_lst: List[int] = []
      self.confidence_level: List[float] = []
      self.poisonous_clusters: np.ndarray
      self.clusterer = MiniBatchKMeans(n_clusters=self.nb_clusters)
      self.ex_re_threshold = ex_re_threshold
      self._check_params()
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import os
  import pickle
  import time
  from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING
  import numpy
  from sklearn.cluster import KMeans, MiniBatchKMeans
  from art import config
  from art.data_generators import DataGenerator
  from art.defences.detector.poison.clustering_analyzer import ClusteringAnalyzer
  from art.defences.detector.poison.ground_truth_evaluator import GroundTruthEvaluator
  from art.defences.detector.poison.poison_filtering_defence import PoisonFilteringDefence
  from art.utils import segment_by_class
  from art.visualization import create_sprite, save_image, plot_3d
label_desc: Use image node_id 1 to create a new ActivationDefence object from inherited base classes: PoisonFilteringDefence with example: obj = ActivationDefence(classifier, x_train, y_train, generator, ex_re_threshold)