class_docstr: Confusion matrix class.
  
  >>> y_actu = [2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]
  >>> y_pred = [0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]
  >>> cm = ConfusionMatrix(y_actu, y_pred)
  >>> cm.classes
  [0, 1, 2]
  >>> cm.table
  {0: {0: 3, 1: 0, 2: 0}, 1: {0: 0, 1: 1, 2: 2}, 2: {0: 2, 1: 1, 2: 3}}
  >>> cm2 = ConfusionMatrix(matrix={"Class1": {"Class1": 1, "Class2": 2}, "Class2": {"Class1": 0, "Class2": 5}})
  >>> cm2
  pycm.ConfusionMatrix(classes: ['Class1', 'Class2'])
class_docstr_tok: ["Confusion","matrix","class",".",">",">",">","y_actu","=","[","2",",","0",",","2",",","2",",","0",",","1",",","1",",","2",",","2",",","0",",","1",",","2","]",">",">",">","y_pred","=","[","0",",","0",",","2",",","1",",","0",",","2",",","1",",","0",",","2",",","0",",","2",",","2","]",">",">",">","cm","=","ConfusionMatrix","(","y_actu",",","y_pred",")",">",">",">","cm.classes","[","0",",","1",",","2","]",">",">",">","cm.table","{","0",":","{","0",":","3",",","1",":","0",",","2",":","0","}",",","1",":","{","0",":","0",",","1",":","1",",","2",":","2","}",",","2",":","{","0",":","2",",","1",":","1",",","2",":","3","}","}",">",">",">","cm2","=","ConfusionMatrix","(","matrix=","{","``","Class1","''",":","{","``","Class1","''",":","1",",","``","Class2","''",":","2","}",",","``","Class2","''",":","{","``","Class1","''",":","0",",","``","Class2","''",":","5","}","}",")",">",">",">","cm2","pycm.ConfusionMatrix","(","classes",":","[","'Class1","'",",","'Class2","'","]",")"]
docstr: Rename the confusion matrix classes.
  
  :param mapping: mapping dictionary
  :type mapping: dict
  :param sort: flag for sorting new classes
  :type sort: bool
  :return: None
code: def relabel(self, mapping, sort=False):
      """
      Rename the confusion matrix classes.
  
      :param mapping: mapping dictionary
      :type mapping: dict
      :param sort: flag for sorting new classes
      :type sort: bool
      :return: None
      """
      if not isinstance(mapping, dict):
          raise pycmMatrixError(MAPPING_FORMAT_ERROR)
      if set(self.classes) != set(mapping.keys()):
          raise pycmMatrixError(MAPPING_CLASS_NAME_ERROR)
      if len(self.classes) != len(set(mapping.values())):
          raise pycmMatrixError(MAPPING_CLASS_NAME_ERROR)
      table_temp = {}
      normalized_table_temp = {}
      for row in self.classes:
          temp_dict = {}
          temp_dict_normalized = {}
          for col in self.classes:
              temp_dict[mapping[col]] = self.table[row][col]
              temp_dict_normalized[
                  mapping[col]
              ] = self.normalized_table[row][col]
          table_temp[mapping[row]] = temp_dict
          normalized_table_temp[mapping[row]] = temp_dict_normalized
      self.table = table_temp
      self.normalized_table = normalized_table_temp
      self.matrix = self.table
      self.normalized_matrix = self.normalized_table
      for param in self.class_stat.keys():
          temp_dict = {}
          for classname in self.classes:
              temp_dict[mapping[classname]] = self.class_stat[param][
                  classname
              ]
          self.class_stat[param] = temp_dict
      temp_label_map = {}
      for prime_label, new_label in self.label_map.items():
          temp_label_map[prime_label] = mapping[new_label]
      self.label_map = temp_label_map
      self.positions = None
      self.classes = [mapping[x] for x in self.classes]
      if sort:
          self.classes = sorted(self.classes)
      self.TP = self.class_stat["TP"]
      self.TN = self.class_stat["TN"]
      self.FP = self.class_stat["FP"]
      self.FN = self.class_stat["FN"]
      __class_stat_init__(self)
  
imports: from __future__ import division
  from .pycm_error import pycmVectorError, pycmMatrixError, pycmCIError, pycmAverageError, pycmPlotError
  from .pycm_handler import __class_stat_init__, __overall_stat_init__
  from .pycm_handler import __obj_assign_handler__, __obj_file_handler__, __obj_matrix_handler__, __obj_vector_handler__, __obj_array_handler__
  from .pycm_handler import __imbalancement_handler__
  from .pycm_class_func import F_calc, IBA_calc, TI_calc, NB_calc, sensitivity_index_calc
  from .pycm_overall_func import weighted_kappa_calc, weighted_alpha_calc, alpha2_calc, brier_score_calc, log_loss_calc
  from .pycm_distance import DistanceType, DISTANCE_MAPPER
  from .pycm_output import *
  from .pycm_util import *
  from .pycm_param import *
  from .pycm_ci import __CI_overall_handler__, __CI_class_handler__
  import os
  import json
  import numpy
  from warnings import warn
label_desc: Use image node_id 26 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.relabel(mapping, sort) without return types