docstr: This method is copied from sklearn. Only used in plot_confusion_matrix but we want to be able
  to normalize upon plotting.
docstr_tok: ["This","method","is","copied","from","sklearn",".","Only","used","in","plot_confusion_matrix","but","we","want","to","be","able","to","normalize","upon","plotting","."]
code: def _maybe_normalize(self, cm, normalize):
      """This method is copied from sklearn. Only used in plot_confusion_matrix but we want to be able
      to normalize upon plotting."""
      with np.errstate(all="ignore"):
          if normalize == "true":
              cm = cm / cm.sum(axis=1, keepdims=True)
          elif normalize == "pred":
              cm = cm / cm.sum(axis=0, keepdims=True)
          elif normalize == "all":
              cm = cm / cm.sum()
      cm = np.nan_to_num(cm)
      return cm
  
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 7 for calling the SimpleConfusionMatrix obj's underlying member method code with example usage: obj._maybe_normalize(cm, normalize) and returns: cm