lenskit.metrics.ranking.RankingMetricBase#

class lenskit.metrics.ranking.RankingMetricBase(n=None, *, k=None)#

Bases: lenskit.metrics._base.Metric

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

Parameters:
  • n (int | None) – Specify the length cutoff for rankings. Rankings longer than this will be truncated prior to measurement.

  • k (int | None) – Deprecated alias for n.

Stability:
Caller (see Stability Levels).
n: int | None = None#

The maximum length of rankings to consider.

property k#
property label#

Default name — class name, optionally @N.

truncate(items)#

Truncate an item list if it is longer than n.

Parameters:

items (lenskit.data.ItemList)