lenskit.metrics.RankWeight#

class lenskit.metrics.RankWeight#

Bases: ABC

Base class for rank weighting models.

This returns multiplicative weights, such that scores should be multiplied by the weights in order to produce weighted scores.

Stability:
Caller (see Stability Levels).
__init__()#

Methods

__init__()

log_weight(ranks)

Compute the (natural) log of the discount for the specified ranks.

series_sum()

Get the sum of the infinite series of this discount function, if known.

weight(ranks)

Compute the discount for the specified ranks.

abstractmethod weight(ranks)#

Compute the discount for the specified ranks.

Ranks must start with 1.

Parameters:

ranks (ndarray[tuple[int], dtype[int32]])

Return type:

ndarray[tuple[int], dtype[float64]]

log_weight(ranks)#

Compute the (natural) log of the discount for the specified ranks.

Ranks must start with 1.

Parameters:

ranks (ndarray[tuple[int], dtype[int32]])

Return type:

ndarray[tuple[int], dtype[float64]]

series_sum()#

Get the sum of the infinite series of this discount function, if known. Some metrics (e.g. RBP()) will use this to normalize their measurements.

Return type:

float | None