lenskit.metrics.ranking.Precision#
- class lenskit.metrics.ranking.Precision(n=None, *, k=None)#
Bases:
lenskit.metrics.ranking._base.ListMetric,lenskit.metrics.ranking._base.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:
- property label#
The metric’s default label in output. The base implementation returns the class name by default.
- measure_list(recs, test)#
Compute measurements for a single list.
- Returns:
A float for simple metrics
Intermediate data for decomposed metrics
A dict mapping metric names to values for multi-metric classes
- Parameters:
recs (lenskit.data.ItemList)
test (lenskit.data.ItemList)
- Return type: