docstr: Convert preds to numpy arrays and calculate the CM
docstr_tok: ["Convert","preds","to","numpy","arrays","and","calculate","the","CM"]
code: def finalize(self):
      """Convert preds to numpy arrays and calculate the CM"""
      assert len(self.target_labels) == len(self.predicted_labels)
      label_ids = list(self.class_map._class2id.values())
      self.confusion_matrix = sklearn.metrics.confusion_matrix(
          y_true=self.target_labels,
          y_pred=self.predicted_labels,
          labels=label_ids,
      )
      if self.print_summary:
          print(self.confusion_matrix)
      self._reset()
      return {"dummy_value_for_fastai": -1}
  
file_path: icevision/icevision/metrics/confusion_matrix/confusion_matrix.py
imports: from icevision.data.prediction import Prediction
  from icevision.metrics.metric import Metric
  from icevision.imports import *
  from icevision.metrics.confusion_matrix.confusion_matrix_utils import *
  import PIL
label_desc: Use image node_id 4 for calling the SimpleConfusionMatrix obj's underlying member method code with example usage: obj.finalize() and returns: dict