Precision (information retrieval) (source code)

= Precision
{disambiguate=information retrieval}
{title2=$\mathrm{TP}/(\mathrm{TP}+\mathrm{FP})$}

<Precision (information retrieval)> measures the relevant fraction of an <information retrieval> system's returned documents. For relevant-document <set> $R$ and nonempty returned-document <set> $S$, it is $|R\cap S|/|S|$. The denominator concerns what was returned, whereas <recall (information retrieval)> concerns all relevant documents.<Introduction to Information Retrieval by Christopher D. Manning and others>[§8.3, printed p.155, equations 8.1 and8.4]{ref}

If $R=\{2,4,6\}$ and $S=\{1,2,3,4,5\}$, two of five returned documents are relevant, giving $2/5=0.4$. Adding irrelevant document seven reduces <precision (information retrieval)> to $2/6$ while leaving <recall (information retrieval)> at $2/3$. This exposes the cost of adding unhelpful results. Returning nothing makes this ratio undefined; a reported score must state any convention used for that case.