information-retrievalprecision-recall

How can i measure precision with this example?


How can I calculated precision . I have the total corpus contains 4000 different sentences. If I did semantic search and got 4 sentences are relevant and one is not relevant which k=5. How can I measure it precision here ? i'm so confused and hope get help

the corpus contains 4000 sentences and there 20 sentences talked about the food. My query is searching for "Sam eat the food " and k=5 gave me the top score using cosine similarity 4 sentences semantically right and there is one is false

enter image description here

here does p1 means k =1 , p2 means k =2 ? so if this is right . will k=1 means that the search for the first sentence has zero result? and for k = 2 , the percentage is 31 ? and so on ?


Solution

  • Precision comes in two ways. Overall precision is the ratio of relevant results among all the search results returned. Precision@k is the ratio of relevant results among the top-k search results returned.

    Therefore your precision@5 will be:

    precision@5 = relevant_results_at_5 / total_search_results_at_5 = 4/5