lenskit.metrics.MeanPopRank#

class lenskit.metrics.MeanPopRank(data, k=None, count='users')#

Bases: ListMetric, RankingMetricBase

Compute 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 (Dataset)

  • k (int | None)

  • count (Literal['users', 'interactions'])

__init__(data, k=None, count='users')#
Parameters:

Methods

__init__(data[, k, count])

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

default

The default value to infer when computing statistics over missing values.

k

The maximum length of rankings to consider.

label

Default name — class name, optionally @K.

item_ranks

measure_list(recs, test)#

Compute the metric value for a single result list.

Individual metric classes need to implement this method.

Parameters:
Return type:

float