lenskit.metrics.ListMetric#

class lenskit.metrics.ListMetric#

Bases: Metric

Base class for metrics that measure individual recommendation (or prediction) lists, and whose results may be aggregated to compute overall metrics.

For prediction metrics, this is macro-averaging.

Default behavior:

Implements summarize() by averaging per-list results (mean, ignoring NaNs).

This class implements the Metric interface in terms of the measure_list method.

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

Methods

__init__()

extract_list_metrics(data, /)

Return the given per-list metric result.

measure_list(output, test, /)

Compute the metric value for a single result list.

summarize(values, /)

Summarize per-list metric values

Attributes

default

label

The metric's default label in output.

abstractmethod measure_list(output, test, /)#

Compute the metric value for a single result list.

Individual metric classes need to implement this method.

Parameters:
Return type:

float

extract_list_metrics(data, /)#

Return the given per-list metric result.

Parameters:

data (Any)

Return type:

float

summarize(values, /)#

Summarize per-list metric values

Returns:

A dictionary containing mean, median, and std.

Parameters:

values (list[Any] | Array | ChunkedArray)

Return type:

dict[str, float | None]