lenskit.metrics.ranking.MeanPopRank#
- class lenskit.metrics.ranking.MeanPopRank(data, *, n=None, k=None, count='users')#
Bases:
lenskit.metrics.ranking._base.ListMetric,lenskit.metrics.ranking._base.RankingMetricBaseCompute the _obscurity_ (mean popularity rank) of the recommendations.
Unlike other metrics, this metric requires access to the training dataset in order to compute item popularity metrics. Supply this as a constructor parameter.
This metric represents the popularity rank as a quantile, based on the either the number of distinct users who have interacted with the item, or the total interactions (depending on the options — distinct users is the default).
Let $q_i$ be the _popularity rank_, represented as a quantile, of item $i$. $q_i = 1$ for the most-popular item; $q_i=0$ for an item with no users or interactions (the quantiles are min-max scaled). This metric computes the mean of the quantile popularity ranks for the recommended items:
\[\mathcal{M}(L) = \frac{1}{|L|} \sum_{i \in L} q_i\]This metric is based on the ``obscurity’’ metric of Ekstrand and Mahant [EM17] and the popularity-based item novelty metric of Vargas and Castells [VC11].
- Stability:
- Caller (see Stability Levels).
- Parameters:
data (lenskit.data.Dataset)
n (int | None)
k (int | None)
count (Literal['users', 'interactions'])
- item_ranks: pandas.Series[float]#
- 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: