lenskit.metrics.GlobalMetric#

class lenskit.metrics.GlobalMetric#

Bases: Metric

Base class for metrics that measure entire runs at a time.

For prediction metrics, this is micro-averaging.

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

Methods

__init__()

extract_list_metrics(data, /)

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

measure_list(output, test, /)

Compute measurements for a single list.

measure_run(output, test, /)

Compute a metric value for an entire run.

summarize(values, /)

Aggregate intermediate values into summary statistics.

Attributes

label

The metric's default label in output.

abstractmethod measure_run(output, test, /)#

Compute a metric value for an entire run.

Individual metric classes need to implement this method.

Parameters:
Return type:

float

measure_list(output, test, /)#

Compute measurements for a single list.

Returns:

  • A float for simple metrics

  • Intermediate data for decomposed metrics

  • A dict mapping metric names to values for multi-metric classes

Parameters:
Return type:

Any

summarize(values, /)#

Aggregate intermediate values into summary statistics.

Returns:

A dictionary of summary statistics.

Parameters:

values (list[Any] | Array | ChunkedArray)

Return type:

float