code: def from_labels_and_predictions(labels, predictions, num_classes):
      '''Compute a confusion matrix from labels and predictions.
      
      A drop-in replacement for tf.confusion_matrix that works on CPU data
      and not tensors.
  
      Params
      ------
      labels : array-like 
          1-D array of real labels for classification
      predicitions: array-like
          1-D array of predicted label classes
      num_classes: scalar
          Total number of classes
  
      Returns
      -------
      matrix : NxN array
          Array of shape [num_classes, num_classes] containing the confusion values.
      ''' 
      assert len(labels) == len(predictions)   
      cm = np.zeros((num_classes, num_classes), dtype=np.int32)
      for i in range(len(labels)):
          cm[labels[i], predictions[i]] += 1
      return cf from_labels_and_predictions(labels, predictions, num_classes):
      '''Compute a confusion matrix from labels and predictions.
      
      A drop-in replacement for tf.confusion_matrix that works on CPU data
      and not tensors.
  
      Params
      ------
      labels : array-like 
          1-D array of real labels for classification
      predicitions: array-like
          1-D array of predicted label classes
      num_classes: scalar
          Total number of classes
  
      Returns
      -------
      matrix : NxN array
          Array of shape [num_classes, num_classes] containing the confusion values.
      ''' 
      assert len(labels) == len(predictions)   
      cm = np.zeros((num_classes, num_classes), dtype=np.int32)
      for i in range(len(labels)):
          cm[labels[i], predictions[i]] += 1
      return cm
docs: Compute a confusion matrix from labels and predictions.
      
      A drop-in replacement for tf.confusion_matrix that works on CPU data
      and not tensors.
  
      Params
      ------
      labels : array-like 
          1-D array of real labels for classification
      predicitions: array-like
          1-D array of predicted label classes
      num_classes: scalar
          Total number of classes
  
      Returns
      -------
      matrix : NxN array
          Array of shape [num_classes, num_classes] containing the confusion values.