from tensorflow.python.ops import math_ops

# 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(
        math_ops.greater_equal(predictions, threshold)),
                                labels=targets)

  return _streaming_metrics


class _MetricKeys(object):
  AUC = "auc"
  PREDICTION_MEAN = "labels/prediction_mean"
  TARGET_MEAN = "labels/actual_target_mean"
  ACCURACY_BASELINE = "accuracy/baseline_target_mean"
  ACCURACY_MEAN = "accuracy/threshold_%f_mean"
  PRECISION_MEAN = "precision/positive_threshold_%f_mean"
