lenskit.metrics.ranking#

LensKit ranking (and list) metrics.

Classes#

RankingMetricBase

Base class for most ranking metrics, implementing an n parameter for

DCG

Compute the _unnormalized_ discounted cumulative gain [JarvelinKekalainen02].

NDCG

Compute the normalized discounted cumulative gain [JarvelinKekalainen02].

Entropy

Evaluate diversity using Shannon entropy over item categories.

RankBiasedEntropy

Evaluate diversity using rank-biased Shannon entropy over item categories.

ExposureGini

Measure exposure distribution of recommendations with the Gini coefficient.

ListGini

Measure item diversity of recommendations with the Gini coefficient.

Hit

Compute whether or not a list is a hit; any list with at least one

ILS

Evaluate recommendation diversity using intra-list similarity (ILS).

AveragePrecision

Compute Average Precision (AP) for a single user's recommendations. This is

MeanPopRank

Compute the _obscurity_ (mean popularity rank) of the recommendations.

Precision

Compute recommendation precision. This is computed as:

Recall

Compute recommendation recall. This is computed as:

RBP

Evaluate recommendations with rank-biased precision [MZ08].

RecipRank

Compute the reciprocal rank [KV97] of the first relevant

GeometricRankWeight

Geometric cascade weighting for result ranks.

LogRankWeight

Logarithmic weighting for result ranks, as used in NDCG.

RankWeight

Base class for rank weighting models.

Functions#

rank_biased_precision(good, weights[, normalization])

Compute rank-biased precision given explicit weights.

Package Contents#

lenskit.metrics.ranking.rank_biased_precision(good, weights, normalization=1.0)#

Compute rank-biased precision given explicit weights.

Parameters:
  • good (numpy.ndarray) – Boolean array indicating relevant items at each position.

  • weights (numpy.ndarray) – Weight for each item position (same length as good).

  • normalization (float) – Optional normalization factor, defaults to 1.0.

Returns:

RBP score

Return type:

float