parameters: (self, eval_loss, predictions, labels, weights)
return_statement: return metrics
docstring: Returns a dict of metrics keyed by name.
docstring_summary: Returns a dict of metrics keyed by name.
docstring_tokens: Returns a dict of metrics keyed by name .
function: def _metrics(self, eval_loss, predictions, labels, weights):
      """Returns a dict of metrics keyed by name."""
      with ops.name_scope("metrics", values=(
          [eval_loss, labels, weights] + list(six.itervalues(predictions)))):
        classes = predictions[prediction_key.PredictionKey.CLASSES]
        probabilities = predictions[prediction_key.PredictionKey.PROBABILITIES]
        logits = predictions[prediction_key.PredictionKey.LOGITS]
  
        metrics = {_summary_key(self.head_name, mkey.LOSS):
                   metrics_lib.mean(eval_loss)}
        # TODO(b/29366811): This currently results in both an "accuracy" and an
        # "accuracy/threshold_0.500000_mean" metric for binary classification.
        metrics[_summary_key(self.head_name, mkey.ACCURACY)] = (
            metrics_lib.accuracy(labels, classes, weights))
        metrics[_summary_key(self.head_name, mkey.AUC)] = _streaming_auc(
            probabilities, labels, weights)
        metrics[_summary_key(self.head_name, mkey.AUC_PR)] = _streaming_auc(
            probabilities, labels, weights, curve="PR")
  
        for class_id in self._metric_class_ids:
          # TODO(ptucker): Add per-class accuracy, precision, recall.
          metrics[_summary_key(
              self.head_name, mkey.CLASS_PREDICTION_MEAN % class_id)] = (
                  _predictions_streaming_mean(classes, weights, class_id))
          metrics[_summary_key(
              self.head_name, mkey.CLASS_LABEL_MEAN % class_id)] = (
                  _indicator_labels_streaming_mean(labels, weights, class_id))
          metrics[_summary_key(
              self.head_name, mkey.CLASS_PROBABILITY_MEAN % class_id)] = (
                  _predictions_streaming_mean(probabilities, weights, class_id))
          metrics[_summary_key(
              self.head_name, mkey.CLASS_LOGITS_MEAN % class_id)] = (
                  _predictions_streaming_mean(logits, weights, class_id))
          metrics[_summary_key(self.head_name, mkey.CLASS_AUC % class_id)] = (
              _streaming_auc(probabilities, labels, weights, class_id))
          metrics[_summary_key(self.head_name, mkey.CLASS_AUC_PR % class_id)] = (
              _streaming_auc(probabilities, labels, weights, class_id,
                             curve="PR"))
  
      return metrics
function_tokens: def _metrics ( self , eval_loss , predictions , labels , weights ) : with ops . name_scope ( "metrics" , values = ( [ eval_loss , labels , weights ] + list ( six . itervalues ( predictions ) ) ) ) : classes = predictions [ prediction_key . PredictionKey . CLASSES ] probabilities = predictions [ prediction_key . PredictionKey . PROBABILITIES ] logits = predictions [ prediction_key . PredictionKey . LOGITS ] metrics = { _summary_key ( self . head_name , mkey . LOSS ) : metrics_lib . mean ( eval_loss ) } # TODO(b/29366811): This currently results in both an "accuracy" and an # "accuracy/threshold_0.500000_mean" metric for binary classification. metrics [ _summary_key ( self . head_name , mkey . ACCURACY ) ] = ( metrics_lib . accuracy ( labels , classes , weights ) ) metrics [ _summary_key ( self . head_name , mkey . AUC ) ] = _streaming_auc ( probabilities , labels , weights ) metrics [ _summary_key ( self . head_name , mkey . AUC_PR ) ] = _streaming_auc ( probabilities , labels , weights , curve = "PR" ) for class_id in self . _metric_class_ids : # TODO(ptucker): Add per-class accuracy, precision, recall. metrics [ _summary_key ( self . head_name , mkey . CLASS_PREDICTION_MEAN % class_id ) ] = ( _predictions_streaming_mean ( classes , weights , class_id ) ) metrics [ _summary_key ( self . head_name , mkey . CLASS_LABEL_MEAN % class_id ) ] = ( _indicator_labels_streaming_mean ( labels , weights , class_id ) ) metrics [ _summary_key ( self . head_name , mkey . CLASS_PROBABILITY_MEAN % class_id ) ] = ( _predictions_streaming_mean ( probabilities , weights , class_id ) ) metrics [ _summary_key ( self . head_name , mkey . CLASS_LOGITS_MEAN % class_id ) ] = ( _predictions_streaming_mean ( logits , weights , class_id ) ) metrics [ _summary_key ( self . head_name , mkey . CLASS_AUC % class_id ) ] = ( _streaming_auc ( probabilities , labels , weights , class_id ) ) metrics [ _summary_key ( self . head_name , mkey . CLASS_AUC_PR % class_id ) ] = ( _streaming_auc ( probabilities , labels , weights , class_id , curve = "PR" ) ) return metrics