class_docstr: Class to evaluate the performance of the poison detection method.
docstr: Computes and returns a json object that contains the confusion matrix for each class.
  
  :param values: Array indicating the correctness of each assignment in the ith class.
  :return: Json object with confusion matrix per-class.
code: def get_confusion_matrix(self, values: np.ndarray) -> dict:
      """
      Computes and returns a json object that contains the confusion matrix for each class.
  
      :param values: Array indicating the correctness of each assignment in the ith class.
      :return: Json object with confusion matrix per-class.
      """
      dic_class = {}
      true_positive = np.where(values == 0)[0].shape[0]
      true_negative = np.where(values == 1)[0].shape[0]
      false_positive = np.where(values == 2)[0].shape[0]
      false_negative = np.where(values == 3)[0].shape[0]
  
      tp_rate = self.calculate_and_print(
          true_positive,
          true_positive + false_negative,
          "true-positive rate",
      )
      tn_rate = self.calculate_and_print(
          true_negative,
          false_positive + true_negative,
          "true-negative rate",
      )
      fp_rate = self.calculate_and_print(
          false_positive,
          false_positive + true_negative,
          "false-positive rate",
      )
      fn_rate = self.calculate_and_print(
          false_negative,
          true_positive + false_negative,
          "false-negative rate",
      )
  
      dic_tp = dict(
          rate=round(tp_rate, 2),
          numerator=true_positive,
          denominator=(true_positive + false_negative),
      )
      if (true_positive + false_negative) == 0:
          dic_tp = dict(
              rate=-1,
              numerator=true_positive,
              denominator=(true_positive + false_negative),
          )
  
      dic_tn = dict(
          rate=round(tn_rate, 2),
          numerator=true_negative,
          denominator=(false_positive + true_negative),
      )
      if (false_positive + true_negative) == 0:
          dic_tn = dict(
              rate=-1,
              numerator=true_negative,
              denominator=(false_positive + true_negative),
          )
  
      dic_fp = dict(
          rate=round(fp_rate, 2),
          numerator=false_positive,
          denominator=(false_positive + true_negative),
      )
      if (false_positive + true_negative) == 0:
          dic_fp = dict(
              rate=-1,
              numerator=false_positive,
              denominator=(false_positive + true_negative),
          )
  
      dic_fn = dict(
          rate=round(fn_rate, 2),
          numerator=false_negative,
          denominator=(true_positive + false_negative),
      )
      if (true_positive + false_negative) == 0:
          dic_fn = dict(
              rate=-1,
              numerator=false_negative,
              denominator=(true_positive + false_negative),
          )
  
      dic_class.update(dict(TruePositive=dic_tp))
      dic_class.update(dict(TrueNegative=dic_tn))
      dic_class.update(dict(FalsePositive=dic_fp))
      dic_class.update(dict(FalseNegative=dic_fn))
  
      return dic_class
  
file_path: adversarial-robustness-toolbox/art/defences/detector/poison/ground_truth_evaluator.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import json
  import logging
  from typing import Tuple, Union, List
  import numpy
label_desc: Use image node_id 3 for calling the GroundTruthEvaluator obj's underlying member method code with example usage: obj.get_confusion_matrix(values) and returns: dic_class