average_precision_at_k如何计算mAP?

时间:2018-08-09 12:16:36

标签: tensorflow

作为以下测试,我将k设置为1,输出为0.2,看来average_precision_at_k使用0.5作为阈值视pred为TP? 在测试中,第一行0.6中只有[0.1, 0.2, 0.6, 0.1]是> 0.5

source code中,找不到阈值定义。

from pprint import pprint
import tensorflow as tf
from sklearn.preprocessing import label_binarize

y_true = np.array([[2], [1], [0], [3], [0]]).astype(np.int64)
y_true = tf.identity(y_true)

y_pred = np.array([[0.1, 0.2, 0.6, 0.1],
                   [0.7, 0.1, 0.1, 0.1],
                   [0.3, 0.4, 0.1, 0.2],
                   [0.5, 0.3, 0.1, 0.1],
                   [0.1, 0.1, 0.7, 0.1]]).astype(np.float32)
y_pred = tf.identity(y_pred)

_, m_ap = tf.metrics.average_precision_at_k(y_true, y_pred, k=1)

sess = tf.Session()
sess.run(tf.local_variables_initializer())

tf_map = sess.run(m_ap)
pprint(tf_map)

0.2

0 个答案:

没有答案