(class_id, logits, targets)
return precision
Computes the precision for class_id.

  The precision for a class is defined as the number of examples of that class
  that are correctly classified over its total number of examples.

  Args:
    class_id: An int, in the range between 0 and the number of classes.
    logits: A float array, of shape [num_test_examples, num_classes].
    targets: An int array, of the same shape as logits.

  Returns:
    precision: A float. The precision for the given class.
Computes the precision for class_id.
Computes the precision for class_id .
def compute_class_precision(class_id, logits, targets):
  """Computes the precision for class_id.

  The precision for a class is defined as the number of examples of that class
  that are correctly classified over its total number of examples.

  Args:
    class_id: An int, in the range between 0 and the number of classes.
    logits: A float array, of shape [num_test_examples, num_classes].
    targets: An int array, of the same shape as logits.

  Returns:
    precision: A float. The precision for the given class.
  """
  # Get the section of the logits that correspond to class_id.
  class_logits_ids = np.where(targets == class_id)[0]
  # [# test examples of class_id, way].
  class_logits = logits[class_logits_ids]
  # [# test examples of class_id]
  class_preds = np.argmax(class_logits, axis=1)
  precision = np.mean(np.equal(class_preds, class_id))
  return precision
def compute_class_precision ( class_id , logits , targets ) : # Get the section of the logits that correspond to class_id. class_logits_ids = np . where ( targets == class_id ) [ 0 ] # [# test examples of class_id, way]. class_logits = logits [ class_logits_ids ] # [# test examples of class_id] class_preds = np . argmax ( class_logits , axis = 1 ) precision = np . mean ( np . equal ( class_preds , class_id ) ) return precision