lenskit.metrics.RankingMetricBase#

class lenskit.metrics.RankingMetricBase(k=None)#

Bases: Metric

Base class for most ranking metrics, implementing a k parameter for truncation.

Parameters:

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

Stability:
Caller (see Stability Levels).
__init__(k=None)#
Parameters:

k (int | None)

Methods

__init__([k])

truncate(items)

Truncate an item list if it is longer than k.

Attributes

k

The maximum length of rankings to consider.

label

Default name — class name, optionally @K.

k: int | None = None#

The maximum length of rankings to consider.

property label#

Default name — class name, optionally @K.

truncate(items)#

Truncate an item list if it is longer than k.

Parameters:

items (ItemList)