lenskit.metrics.RecipRank#
- class lenskit.metrics.RecipRank(n=None, *, k=None)#
Bases:
ListMetric,RankingMetricBaseCompute the reciprocal rank [KV97] of the first relevant item in a list of recommendations. Taking the mean of this metric over the recommendation lists in a run yields the MRR (mean reciprocal rank).
Let \(\kappa\) denote the 1-based rank of the first relevant item in \(L\), with \(\kappa=\infty\) if none of the first \(k\) items in \(L\) are relevant; then the reciprocal rank is \(1 / \kappa\). If no elements are relevant, the reciprocal rank is therefore 0. Deshpande and Karypis [DK04] call this the “reciprocal hit rate”.
- Stability:
- Caller (see Stability Levels).
- Parameters:
Methods
__init__([n, k])extract_list_metrics(data, /)Return the given per-list metric result.
measure_list(recs, test)Compute the metric value for a single result list.
summarize(values, /)Summarize per-list metric values
truncate(items)Truncate an item list if it is longer than
n.Attributes
defaultkThe metric's default label in output.
nThe maximum length of rankings to consider.
set_k- property label#
The metric’s default label in output. The base implementation returns the class name by default.