lenskit.metrics.RankingMetricBase#

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

Bases: 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).
__init__(n=None, *, k=None)#
Parameters:
  • n (int | None)

  • k (int | None)

Methods

__init__([n, k])

extract_list_metrics(data, /)

Extract per-list metric(s) from intermediate measurement data.

measure_list(output, test, /)

Compute measurements for a single list.

summarize(values, /)

Aggregate intermediate values into summary statistics.

truncate(items)

Truncate an item list if it is longer than n.

Attributes

k

label

Default name — class name, optionally @N.

n

The maximum length of rankings to consider.

set_k

n: int | None = None#

The maximum length of rankings to consider.

property label#

Default name — class name, optionally @N.

truncate(items)#

Truncate an item list if it is longer than n.

Parameters:

items (ItemList)