Recall¶
召回率Recall(也称为敏感度)是指得到的相关实例数占相关实例总数的比例。https://en.wikipedia.org/wiki/Precision_and_recall 该类管理二分类任务的召回率。
代码示例¶
import paddle.fluid as fluid
import numpy as np
metric = fluid.metrics.Recall()
# 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=preds, labels=labels)
numpy_recall = metric.eval()
print("expect recall: %.2f and got %.2f" % ( 3.0 / 4.0, numpy_recall))