lenskit.metrics.Precision#
- class lenskit.metrics.Precision(k=None)#
Bases:
ListMetric,RankingMetricBaseCompute recommendation precision. This is computed as:
\[\frac{|L \cap I_u^{\mathrm{test}}|}{|L|}\]In the uncommon case that
kis specified andlen(recs) < k, this metric useslen(recs)as the denominator.- Stability:
- Caller (see Stability Levels).
- Parameters:
k (int | None)
Methods
__init__([k])measure_list(recs, test)Compute the metric value for a single result list.
truncate(items)Truncate an item list if it is longer than
k.Attributes
defaultThe default value to infer when computing statistics over missing values.
kThe maximum length of rankings to consider.
The metric's default label in output.
- property label#
The metric’s default label in output.
The base implementation returns the class name by default.