mAP的是各个类别的AP的值的平均值
# https://blog.csdn.net/qq_36523492/article/details/108469465 计算方法选择第二种方法 the interpolation performed in all points # 定义一个列表 lst = [3, 1, 4, 2] # 使用sorted函数对列表进行排序,并获取原始元素在排序后列表中的索引 indexes = sorted(range(len(lst)), key=lambda x: lst[x]) print(indexes) print(lst) def cacluate_AP(recall_list, precision_list): '''the interpolation performed in all points''' assert len(recall_list) == len(precision_list) recall_sort_index = sorted(range(len(recall_list)), key=lambda x: recall_list[x]) recall_list = [recall_list[x] for x in recall_sort_index] precision_list = [precision_list[x] for x in recall_sort_index] ap_value = 0 last_recall = 0 for index, recall in enumerate(recall_list): ap_value += precision_list[index] * (recall - last_recall) last_recall = recall return ap_value if __name__ == '__main__': print(cacluate_AP([0.1, 0.3, 0.2], [1, 1, 1]))
标签:mAP,lst,index,recall,list,precision,AP,算法 From: https://www.cnblogs.com/lycsdhr/p/17914669.html