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, self._labels(labels), self._label_ids(labels),
                   weights) + tuple(six.itervalues(predictions)))):
        logits = predictions[prediction_key.PredictionKey.LOGITS]
        probabilities = predictions[prediction_key.PredictionKey.PROBABILITIES]
        classes = predictions[prediction_key.PredictionKey.CLASSES]
  
        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(self._labels(labels), classes, weights))
  
        if not self._label_keys:
          # Classes are IDs. Add some metrics.
          for class_id in self._metric_class_ids:
            metrics[_summary_key(
                self.head_name, mkey.CLASS_PREDICTION_MEAN % class_id)] = (
                    _class_predictions_streaming_mean(classes, weights, class_id))
            # TODO(ptucker): Add per-class accuracy, precision, recall.
            metrics[_summary_key(
                self.head_name, mkey.CLASS_LABEL_MEAN % class_id)] = (
                    _class_labels_streaming_mean(
                        self._label_ids(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))
  
      return metrics
function_tokens: def _metrics ( self , eval_loss , predictions , labels , weights ) : with ops . name_scope ( "metrics" , values = ( ( eval_loss , self . _labels ( labels ) , self . _label_ids ( labels ) , weights ) + tuple ( six . itervalues ( predictions ) ) ) ) : logits = predictions [ prediction_key . PredictionKey . LOGITS ] probabilities = predictions [ prediction_key . PredictionKey . PROBABILITIES ] classes = predictions [ prediction_key . PredictionKey . CLASSES ] 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 ( self . _labels ( labels ) , classes , weights ) ) if not self . _label_keys : # Classes are IDs. Add some metrics. for class_id in self . _metric_class_ids : metrics [ _summary_key ( self . head_name , mkey . CLASS_PREDICTION_MEAN % class_id ) ] = ( _class_predictions_streaming_mean ( classes , weights , class_id ) ) # TODO(ptucker): Add per-class accuracy, precision, recall. metrics [ _summary_key ( self . head_name , mkey . CLASS_LABEL_MEAN % class_id ) ] = ( _class_labels_streaming_mean ( self . _label_ids ( 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 ) ) return metrics