JJoeven

Exercises / ml

Precision at k

precision_at_k(ranked, relevant, k) is hits in the first k names divided by k. Ranked is best-first. Print P@2 for names a,b,c with relevant {a,c}.

Live Pythonpython
Output
Run to execute this in your browser. Nothing is sent to a server.