from tensorflow.contrib import metrics as metrics_lib

    metrics[_MetricKeys.PRECISION_MEAN % threshold] = _streaming_with_threshold(
        metrics_lib.streaming_precision, threshold)
    # Recall for positive examples.
    metrics[_MetricKeys.RECALL_MEAN % threshold] = _streaming_with_threshold(
        metrics_lib.streaming_recall, threshold)

  return metrics


# TODO(zakaria): support weights.
def _targets_streaming_mean(unused_predictions, targets):
  return metrics_lib.streaming_mean(targets)


def _predictions_streaming_mean(predictions, unused_targets):
  return metrics_lib.streaming_mean(predictions)


def _streaming_with_threshold(streaming_metrics_fn, threshold):

  def _streaming_metrics(predictions, targets):
    return streaming_metrics_fn(predictions=math_ops.to_float(
