目标检测算法中的AP以及mAP值的计算
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]))
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!