[BUG] Precision calculation incorrect?
See original GitHub issueDescribe the bug In the below example, I would expect run1 to have a precision of 1.0 and I would expect both run2 and run3 to have precisions of 0.75, as 3 out of 4 returned documents are relevant. Instead the second query returns 0.5, and the third 0.25. Either there is a bug handling empty query results, or I have a naive misunderstanding of precision. Also, run 2 and run 3 are similar, just with different queries returning null results. Please correct me if I’m wrong!
To Reproduce Steps to reproduce the behavior:
qrels_dict = {
"q_1": {"doc_a": 1},
"q_2": {"doc_b": 1, "doc_c": 1, "doc_d": 1},
"q_3": {"doc_e": 1},
"q_4": {"doc_f": 1},
}
run_dict_1 = {
"q_1": {"doc_a": 1.0},
"q_2": {"doc_d": 1.0},
"q_3": {"doc_e": 1.0},
"q_4": {"doc_f": 1.0},
}
run_dict_2 = {
"q_1": {"doc_a": 1.0},
"q_2": {"doc_d": 1.0},
"q_3": {},
"q_4": {"doc_f": 1.0},
}
run_dict_3 = {
"q_1": {"doc_a": 1.0},
"q_2": {},
"q_3": {"doc_e": 1.0},
"q_4": {"doc_f": 1.0},
}
qrels = Qrels(qrels_dict)
run1 = Run(run_dict_1)
run2 = Run(run_dict_2)
run3 = Run(run_dict_3)
print(evaluate(qrels, run1, ["precision"]))
print(evaluate(qrels, run2, ["precision"]))
print(evaluate(qrels, run3, ["precision"]))
1.0 0.5 0.25
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
CWE-682: Incorrect Calculation (4.9) - MITRE
The software performs a calculation that generates incorrect or unintended results that are later used in security-critical decisions or resource management.
Read more >Precision, Accuracy and Total Analytical Error
Precision refers to the magnitude of random errors and the re- producibility of measurements.
Read more >Precision, Accuracy, and Error - Mometrix Test Preparation
This video tutorial helps explain the basics of Precision, Accuracy, and Error. Get the best test prep review for your exam!
Read more >Accuracy, Precision, and Error - YouTube
Discussion on the difference between accuracy and precision. Examples of error and percent error calculations.
Read more >Error Analysis — Precision & Recall | by Toby Chitty - Medium
We can calculate our accuracy measure by adding our TP and TN (predictions we go right) and dividing by the total. But as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @kaleko,
Thank you very much for the bug report and for providing a working example!
numba
was not raising aZeroDivisionError
, so I did not spot this issue before. I fixed it inv.0.3.4
. Now it works as intended.Please, consider giving
ranx
a star if you like it!If you find a theoretically sound explanation, please post it here.