Precision

class paddle.fluid.metrics. Precision ( name=None ) [source]

Precision (also called positive predictive value) is the fraction of relevant instances among the retrieved instances. Refer to https://en.wikipedia.org/wiki/Evaluation_of_binary_classifiers

Noted that this class manages the precision score only for binary classification task.

Parameters

name (str, optional) – Metric name. For details, please refer to Name. Default is None.

Examples

import paddle.fluid as fluid
import numpy as np

metric = fluid.metrics.Precision()

# generate the preds and labels

preds = [[0.1], [0.7], [0.8], [0.9], [0.2],
         [0.2], [0.3], [0.5], [0.8], [0.6]]

labels = [[0], [1], [1], [1], [1],
          [0], [0], [0], [0], [0]]

preds = np.array(preds)
labels = np.array(labels)

metric.update(preds