From b4d3eef3debc8a7d2714b2d73282ba1287a0f775 Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Mon, 14 Sep 2020 19:59:40 +0800 Subject: [PATCH] Remove api/paddle/metric/accuracy_cn.rst and api/paddle/metric/auc_cn.rst (#2621) --- doc/paddle/api/paddle/metric/accuracy_cn.rst | 63 ------------------ doc/paddle/api/paddle/metric/auc_cn.rst | 67 -------------------- 2 files changed, 130 deletions(-) delete mode 100644 doc/paddle/api/paddle/metric/accuracy_cn.rst delete mode 100644 doc/paddle/api/paddle/metric/auc_cn.rst diff --git a/doc/paddle/api/paddle/metric/accuracy_cn.rst b/doc/paddle/api/paddle/metric/accuracy_cn.rst deleted file mode 100644 index 0cb6ea087..000000000 --- a/doc/paddle/api/paddle/metric/accuracy_cn.rst +++ /dev/null @@ -1,63 +0,0 @@ -.. _cn_api_fluid_metrics_Accuracy: - -Accuracy -------------------------------- -.. py:class:: paddle.fluid.metrics.Accuracy(name=None) - - - - -该接口用来计算多个mini-batch的平均准确率。Accuracy对象有两个状态value和weight。Accuracy的定义参照 https://en.wikipedia.org/wiki/Accuracy_and_precision 。 - -参数: - - **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。 - -返回:初始化后的 ``Accuracy`` 对象 - -返回类型:Accuracy - -**代码示例** - -.. code-block:: python - - import paddle.fluid as fluid - # 假设有batch_size = 128 - batch_size=128 - accuracy_manager = fluid.metrics.Accuracy() - # 假设第一个batch的准确率为0.9 - batch1_acc = 0.9 - accuracy_manager.update(value = batch1_acc, weight = batch_size) - print("expect accuracy: %.2f, get accuracy: %.2f" % (batch1_acc, accuracy_manager.eval())) - # 假设第二个batch的准确率为0.8 - batch2_acc = 0.8 - accuracy_manager.update(value = batch2_acc, weight = batch_size) - #batch1和batch2的联合准确率为(batch1_acc * batch_size + batch2_acc * batch_size) / batch_size / 2 - print("expect accuracy: %.2f, get accuracy: %.2f" % ((batch1_acc * batch_size + batch2_acc * batch_size) / batch_size / 2, accuracy_manager.eval())) - #重置accuracy_manager - accuracy_manager.reset() - #假设第三个batch的准确率为0.8 - batch3_acc = 0.8 - accuracy_manager.update(value = batch3_acc, weight = batch_size) - print("expect accuracy: %.2f, get accuracy: %.2f" % (batch3_acc, accuracy_manager.eval())) - -.. py:method:: update(value, weight) - -该函数使用输入的(value, weight)来累计更新Accuracy对象的对应状态,更新方式如下: - - .. math:: - \\ \begin{array}{l}{\text { self. value }+=\text { value } * \text { weight }} \\ {\text { self. weight }+=\text { weight }}\end{array} \\ - -参数: - - **value** (float|numpy.array) – mini-batch的正确率 - - **weight** (int|float) – mini-batch的大小 - -返回:无 - -.. py:method:: eval() - -该函数计算并返回累计的mini-batches的平均准确率。 - -返回:累计的mini-batches的平均准确率 - -返回类型:float或numpy.array - diff --git a/doc/paddle/api/paddle/metric/auc_cn.rst b/doc/paddle/api/paddle/metric/auc_cn.rst deleted file mode 100644 index 8e6b7bfea..000000000 --- a/doc/paddle/api/paddle/metric/auc_cn.rst +++ /dev/null @@ -1,67 +0,0 @@ -.. _cn_api_fluid_metrics_Auc: - -Auc -------------------------------- -.. py:class:: paddle.fluid.metrics.Auc(name, curve='ROC', num_thresholds=4095) - - - - -**注意**:目前只用Python实现Auc,可能速度略慢 - -该接口计算Auc,在二分类(binary classification)中广泛使用。相关定义参考 https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve 。 - -该接口创建四个局部变量true_positives, true_negatives, false_positives和false_negatives,用于计算Auc。为了离散化AUC曲线,使用临界值的线性间隔来计算召回率和准确率的值。用false positive的召回值高度计算ROC曲线面积,用recall的准确值高度计算PR曲线面积。 - -参数: - - **name** (str,可选) – 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为None。 - - **curve** (str) - 将要计算的曲线名的详情,曲线包括ROC(默认)或者PR(Precision-Recall-curve)。 - -返回:初始化后的 ``Auc`` 对象 - -返回类型:Auc - -**代码示例**: - -.. code-block:: python - - import paddle.fluid as fluid - import numpy as np - # 初始化auc度量 - auc_metric = fluid.metrics.Auc("ROC") - - # 假设batch_size为128 - batch_num = 100 - batch_size = 128 - - for batch_id in range(batch_num): - - class0_preds = np.random.random(size = (batch_size, 1)) - class1_preds = 1 - class0_preds - - preds = np.concatenate((class0_preds, class1_preds), axis=1) - - labels = np.random.randint(2, size = (batch_size, 1)) - auc_metric.update(preds = preds, labels = labels) - - # 应为一个接近0.5的值,因为preds是随机指定的 - print("auc for iteration %d is %.2f" % (batch_id, auc_metric.eval())) - -.. py:method:: update(preds, labels) - -用给定的预测值和标签更新Auc曲线。 - -参数: - - **preds** (numpy.array) - 维度为[batch_size, 2],preds[i][j]表示将实例i划分为类别j的概率。 - - **labels** (numpy.array) - 维度为[batch_size, 1],labels[i]为0或1,代表实例i的标签。 - -返回:无 - -.. py:method:: eval() - -该函数计算并返回Auc值。 - -返回:Auc值 - -返回类型:float - -- GitLab