ops.GraphKeys.GLOBAL_STEP: 100,
metric_keys.MetricKeys.LOSS_MEAN: 1.3133,
metric_keys.MetricKeys.ACCURACY: 0.,
+ metric_keys.MetricKeys.PRECISION: 0.,
+ metric_keys.MetricKeys.RECALL: 0.,
metric_keys.MetricKeys.PREDICTION_MEAN: 0.2689,
metric_keys.MetricKeys.LABEL_MEAN: 1.,
metric_keys.MetricKeys.ACCURACY_BASELINE: 1,
ops.GraphKeys.GLOBAL_STEP: 100,
metric_keys.MetricKeys.LOSS_MEAN: expected_loss / 2,
metric_keys.MetricKeys.ACCURACY: 0.5,
+ metric_keys.MetricKeys.PRECISION: 0.,
+ metric_keys.MetricKeys.RECALL: 0.,
metric_keys.MetricKeys.PREDICTION_MEAN: 0.2689,
metric_keys.MetricKeys.LABEL_MEAN: 0.5,
metric_keys.MetricKeys.ACCURACY_BASELINE: 0.5,
ops.GraphKeys.GLOBAL_STEP: 100,
metric_keys.MetricKeys.LOSS_MEAN: loss_mean,
metric_keys.MetricKeys.ACCURACY: 2. / (1. + 2.),
+ metric_keys.MetricKeys.PRECISION: 0.,
+ metric_keys.MetricKeys.RECALL: 0.,
metric_keys.MetricKeys.PREDICTION_MEAN: predictions_mean,
metric_keys.MetricKeys.LABEL_MEAN: label_mean,
metric_keys.MetricKeys.ACCURACY_BASELINE: (
if __name__ == '__main__':
test.main()
-
metric_keys.MetricKeys.LOSS: expected_loss,
metric_keys.MetricKeys.LOSS_MEAN: expected_loss / 2.,
metric_keys.MetricKeys.ACCURACY: 0.5,
+ metric_keys.MetricKeys.PRECISION: 0.0,
+ metric_keys.MetricKeys.RECALL: 0.0,
metric_keys.MetricKeys.PREDICTION_MEAN: 0.11105597,
metric_keys.MetricKeys.LABEL_MEAN: 0.5,
metric_keys.MetricKeys.ACCURACY_BASELINE: 0.5,
# that is what the algorithm returns.
metric_keys.MetricKeys.AUC: 0.5,
metric_keys.MetricKeys.AUC_PR: 0.75,
+
ops.GraphKeys.GLOBAL_STEP: global_step
}, dnn_classifier.evaluate(input_fn=_input_fn, steps=1))
predictions=class_ids,
weights=weights,
name=keys.ACCURACY),
+ _summary_key(self._name, keys.PRECISION):
+ metrics_lib.precision(
+ labels=labels,
+ predictions=class_ids,
+ weights=weights,
+ name=keys.PRECISION),
+ _summary_key(self._name, keys.RECALL):
+ metrics_lib.recall(
+ labels=labels,
+ predictions=class_ids,
+ weights=weights,
+ name=keys.RECALL),
_summary_key(self._name, keys.PREDICTION_MEAN):
_predictions_mean(
predictions=logistic,
# loss_mean = loss/2 = 41./2 = 20.5
keys.LOSS_MEAN: 20.5,
keys.ACCURACY: 1./2,
+ keys.PRECISION: 1.,
+ keys.RECALL: 1./2,
keys.PREDICTION_MEAN: 1./2,
keys.LABEL_MEAN: 2./2,
keys.ACCURACY_BASELINE: 2./2,
expected_metric_keys = [
'{}/some_binary_head'.format(metric_keys.MetricKeys.LOSS_MEAN),
'{}/some_binary_head'.format(metric_keys.MetricKeys.ACCURACY),
+ '{}/some_binary_head'.format(metric_keys.MetricKeys.PRECISION),
+ '{}/some_binary_head'.format(metric_keys.MetricKeys.RECALL),
'{}/some_binary_head'.format(metric_keys.MetricKeys.PREDICTION_MEAN),
'{}/some_binary_head'.format(metric_keys.MetricKeys.LABEL_MEAN),
'{}/some_binary_head'.format(metric_keys.MetricKeys.ACCURACY_BASELINE),
'{}/some_binary_head'.format(metric_keys.MetricKeys.AUC),
- '{}/some_binary_head'.format(metric_keys.MetricKeys.AUC_PR)
+ '{}/some_binary_head'.format(metric_keys.MetricKeys.AUC_PR),
]
self.assertItemsEqual(expected_metric_keys, spec.eval_metric_ops.keys())
keys.LOSS_MEAN: expected_unregularized_loss,
keys.LOSS_REGULARIZATION: expected_regularization_loss,
keys.ACCURACY: 1./2,
+ keys.PRECISION: 1.,
+ keys.RECALL: 1./2,
keys.PREDICTION_MEAN: 1./2,
keys.LABEL_MEAN: 2./2,
keys.ACCURACY_BASELINE: 2./2,
expected_metrics = {
keys.LOSS_MEAN: 1.62652338 / 2.,
keys.ACCURACY: 1./2,
+ keys.PRECISION: 1.,
+ keys.RECALL: .5,
keys.PREDICTION_MEAN: 1./2,
keys.LABEL_MEAN: 2./2,
keys.ACCURACY_BASELINE: 2./2,
keys.LOSS_MEAN: 26.9615384615,
# accuracy = (1*1 + .1*0 + 1.5*0)/(1 + .1 + 1.5) = 1/2.6 = .38461538461
keys.ACCURACY: .38461538461,
+ keys.PRECISION: 1./2.5,
+ keys.RECALL: 1./1.1,
# prediction_mean = (1*1 + .1*0 + 1.5*1)/(1 + .1 + 1.5) = 2.5/2.6
# = .96153846153
keys.PREDICTION_MEAN: .96153846153,
expected_metrics = {
keys.LOSS_MEAN: expected_loss / np.sum(weights),
keys.ACCURACY: (1.*0. + 1.5*1. + 2.*1. + 2.5*0.) / np.sum(weights),
+ keys.PRECISION: 2.0/3.0,
+ keys.RECALL: 2.0/4.5,
keys.PREDICTION_MEAN: (1.*1 + 1.5*0 + 2.*1 + 2.5*0) / np.sum(weights),
keys.LABEL_MEAN: (1.*0 + 1.5*0 + 2.*1 + 2.5*1) / np.sum(weights),
keys.ACCURACY_BASELINE: (1.*0 + 1.5*0 + 2.*1 + 2.5*1) / np.sum(weights),
ops.GraphKeys.GLOBAL_STEP: 100,
metric_keys.MetricKeys.LOSS_MEAN: 41.,
metric_keys.MetricKeys.ACCURACY: 0.,
+ metric_keys.MetricKeys.PRECISION: 0.,
+ metric_keys.MetricKeys.RECALL: 0.,
metric_keys.MetricKeys.PREDICTION_MEAN: 0.,
metric_keys.MetricKeys.LABEL_MEAN: 1.,
metric_keys.MetricKeys.ACCURACY_BASELINE: 1,
ops.GraphKeys.GLOBAL_STEP: 100,
metric_keys.MetricKeys.LOSS_MEAN: expected_loss / 2,
metric_keys.MetricKeys.ACCURACY: 0.,
+ metric_keys.MetricKeys.PRECISION: 0.,
+ metric_keys.MetricKeys.RECALL: 0.,
metric_keys.MetricKeys.PREDICTION_MEAN: 0.5,
metric_keys.MetricKeys.LABEL_MEAN: 0.5,
metric_keys.MetricKeys.ACCURACY_BASELINE: 0.5,
ops.GraphKeys.GLOBAL_STEP: 100,
metric_keys.MetricKeys.LOSS_MEAN: loss_mean,
metric_keys.MetricKeys.ACCURACY: 0.,
+ metric_keys.MetricKeys.PRECISION: 0.,
+ metric_keys.MetricKeys.RECALL: 0.,
metric_keys.MetricKeys.PREDICTION_MEAN: predictions_mean,
metric_keys.MetricKeys.LABEL_MEAN: label_mean,
metric_keys.MetricKeys.ACCURACY_BASELINE: (
LOSS_REGULARIZATION = 'regularization_loss'
ACCURACY = 'accuracy'
+ PRECISION = 'precision'
+ RECALL = 'recall'
# This is the best the model could do by always predicting one class.
# Should be < ACCURACY in a trained model.
ACCURACY_BASELINE = 'accuracy_baseline'