# ChunkEvaluator¶

class paddle.fluid.metrics. ChunkEvaluator ( name=None ) [源代码]

## 参数¶

• name (str，可选) - 具体用法请参见 Name，一般无需设置，默认值为 None。

ChunkEvaluator

## 代码示例¶

import paddle.fluid as fluid
# init the chunk-level evaluation manager
metric = fluid.metrics.ChunkEvaluator()

# suppose the model predict 10 chucks, while 8 ones are correct and the ground truth has 9 chucks.
num_infer_chunks = 10
num_label_chunks = 9
num_correct_chunks = 8

metric.update(num_infer_chunks, num_label_chunks, num_correct_chunks)
numpy_precision, numpy_recall, numpy_f1 = metric.eval()

print("precision: %.2f, recall: %.2f, f1: %.2f" % (numpy_precision, numpy_recall, numpy_f1))

# the next batch, predicting 3 perfectly correct chucks.
num_infer_chunks = 3
num_label_chunks = 3
num_correct_chunks = 3

metric.update(num_infer_chunks, num_label_chunks, num_correct_chunks)
numpy_precision, numpy_recall, numpy_f1 = metric.eval()

print("precision: %.2f, recall: %.2f, f1: %.2f" % (numpy_precision, numpy_recall, numpy_f1))


## 方法¶

### update(num_infer_chunks, num_label_chunks, num_correct_chunks)¶

$\begin{split}\\ \begin{array}{l}{\text { self. num_infer_chunks }+=\text { num_infer_chunks }} \\ {\text { self. num_Label_chunks }+=\text { num_label_chunks }} \\ {\text { self. num_correct_chunks }+=\text { num_correct_chunks }}\end{array} \\\end{split}$

• num_infer_chunks (int|numpy.array) – 给定mini-batch的语块数目。

• num_label_chunks (int|numpy.array) - 给定mini-batch的标签中的语块数目。

• num_correct_chunks （int|numpy.array）— 给定mini-batch的正确识别的语块数目。