# MAP

Problem Description
Many people get information from Baidu、Google、Bing and so on. OK, now we will consider how to test the performance of a search system.
The testing is based on an annotation file，annotation file consist of some query，every query has a query word and many reference URL. For example，“MM xxoo.com ooxx.com xoxo.com”，“MM”is the query word and “xxoo.com ooxx.com xoxo.com”is the reference URL.
If we search the query word from search system, we can also get a result list, and then we can test the search performance by the result list and annotation file. You job is calculate the MAP of the search performance. The definition of MAP is：
Rank:
Position of a retrieved URL in the list of retrieved list.
Precision at a given cut-off rank r for a single query:
P(r) = (number of relevant URL of rank r or less) / r
Average precision: defined as follows

Where N is the number of retrieved URL, R is the number of relevant URL, and rel(r) = 1 if URL at rank r is relevant, 0 otherwise.
Mean average precision: average precision for a set of queries is defined as follows:

Where Q is the number of queries.

Input
The first line of input contains T, the number of test cases.
For each test case start with a number n, the query number of annotation file. Then follows 2n lines, the first n lines are the annotation, every line means a query that has a word in front and the reference URL followed. The next n lines are the search result of the queries in annotation, every line means the search result of a query that has the search word in front and the retrieved URL followed.
n <= 100.
The length of a line <= 10000.
The length of a URL and word <= 50.

Output
Case number ant the MAP value with 6 digits after decimal point.

Sample Input
1
3
Banana banana.com
Banana asd.com banana.com
Software gdf.com wer.com tre.com

Sample Output
Case #1: 0.361111

• 写回答

#### 1条回答默认 最新

• threenewbee 2017-11-29 15:47
关注
本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

#### 悬赏问题

• ¥15 爬取豆瓣电影相关处理
• ¥15 手机淘宝抓清除消息接口
• ¥15 C#无selenium
• ¥15 LD衰减计算的结果过大
• ¥15 用机器学习方法帮助保险公司预测哪些是欺诈行为
• ¥15 计算300m以内的LD衰减
• ¥15 数据爬取，python
• ¥15 怎么看 cst中一个面的功率分布图，请说明详细步骤。类似下图
• ¥15 为什么我的pycharm无法用pyqt6的QtWebEngine
• ¥15 FOR循环语句显示查询超过300S错误怎么办