class_docstr: Method from Tran et al., 2018 performing poisoning detection based on Spectral Signatures
class_docstr_tok: ["Method","from","Tran","et","al.",",","2018","performing","poisoning","detection","based","on","Spectral","Signatures"]
docstr: :param matrix_r: Matrix of feature representations.
  :return: Outlier scores for each observation based on spectral signature.
docstr_tok: [":","param","matrix_r",":","Matrix","of","feature","representations",".",":","return",":","Outlier","scores","for","each","observation","based","on","spectral","signature","."]
code: def spectral_signature_scores(matrix_r: np.ndarray) -> np.ndarray:
      """
      :param matrix_r: Matrix of feature representations.
      :return: Outlier scores for each observation based on spectral signature.
      """
      matrix_m = matrix_r - np.mean(matrix_r, axis=0)
      # Following Algorithm #1 in paper, use SVD of centered features, not of covariance
      _, _, matrix_v = np.linalg.svd(matrix_m, full_matrices=False)
      eigs = matrix_v[:1]
      corrs = np.matmul(eigs, np.transpose(matrix_r))
      score = np.expand_dims(np.linalg.norm(corrs, axis=0), axis=1)
      return score
  
file_path: adversarial-robustness-toolbox/art/defences/detector/poison/spectral_signature_defense.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from typing import List, Tuple, TYPE_CHECKING
  import numpy
  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
label_desc: Use image node_id 5 for calling the SpectralSignatureDefense obj's underlying member method code with example usage: obj.spectral_signature_scores(matrix_r) and returns: score