class_docstr: Implements methods performing poisoning detection based on data provenance.
  
  | Paper link: https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8473440
class_docstr_tok: ["Implements","methods","performing","poisoning","detection","based","on","data","provenance",".","|","Paper","link",":","https",":","\/\/ieeexplore.ieee.org\/stamp\/stamp.jsp","?","tp=","&","arnumber=8473440"]
docstr: Detect poison given trusted validation data
  
  :return: dictionary where keys are suspected poisonous device indices and values are performance differences
docstr_tok: ["Detect","poison","given","trusted","validation","data",":","return",":","dictionary","where","keys","are","suspected","poisonous","device","indices","and","values","are","performance","differences"]
code: def detect_poison_partially_trusted(
      self, **kwargs
  ) -> Dict[int, float]:
      """
      Detect poison given trusted validation data
  
      :return: dictionary where keys are suspected poisonous device indices and values are performance differences
      """
      self.set_params(**kwargs)
  
      if self.x_val is None or self.y_val is None:
          raise ValueError("Trusted data unavailable.")
  
      suspected = {}
      unfiltered_data = np.copy(self.x_train)
      unfiltered_labels = np.copy(self.y_train)
  
      segments = segment_by_class(
          self.x_train, self.p_train, self.num_devices
      )
      for device_idx, segment in enumerate(segments):
          filtered_data, filtered_labels = self.filter_input(
              unfiltered_data, unfiltered_labels, segment
          )
  
          unfiltered_model = deepcopy(self.classifier)
          filtered_model = deepcopy(self.classifier)
  
          unfiltered_model.fit(unfiltered_data, unfiltered_labels)
          filtered_model.fit(filtered_data, filtered_labels)
  
          var_w = performance_diff(
              filtered_model,
              unfiltered_model,
              self.x_val,
              self.y_val,
              perf_function=self.perf_func,
          )
          if self.eps < var_w:
              suspected[device_idx] = var_w
              unfiltered_data = filtered_data
              unfiltered_labels = filtered_labels
  
      return suspected
  
file_path: adversarial-robustness-toolbox/art/defences/detector/poison/provenance_defense.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from copy import deepcopy
  from typing import Dict, List, Optional, Tuple, 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 segment_by_class, performance_diff
label_desc: Use image node_id 4 for calling the ProvenanceDefense obj's underlying member method code with example usage: obj.detect_poison_partially_trusted() and returns: suspected