lenskit.metrics.ranking.RankWeight#

class lenskit.metrics.ranking.RankWeight#

Bases: abc.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).
abstractmethod weight(ranks)#

Compute the discount for the specified ranks.

Ranks must start with 1.

Parameters:

ranks (lenskit.data.types.NPVector[numpy.int32])

Return type:

lenskit.data.types.NPVector[numpy.float64]

log_weight(ranks)#

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

Ranks must start with 1.

Parameters:

ranks (lenskit.data.types.NPVector[numpy.int32])

Return type:

lenskit.data.types.NPVector[numpy.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