lenskit.metrics.RunAnalysis#

class lenskit.metrics.RunAnalysis(*metrics)#

Bases: object

Compute metrics over a collection of item lists composing a run.

This class now uses MetricAccumulator internally to separate accumulation from looping, while maintaining the same external interface.

Parameters:

metrics (Metric) – A list of metrics; you can also add them with add_metric(), which provides more flexibility.

Stability:
Caller (see Stability Levels).
__init__(*metrics)#
Parameters:

metrics (Metric)

Methods

__init__(*metrics)

add_metric(metric[, label, default])

Add a metric to this metric set.

compute(outputs, test)

Deprecated alias for measure().

measure(outputs, test)

Measure a set of outputs against a set of test data.

Attributes

metrics

The list of metrics to compute.

add_metric(metric, label=None, default=None)#

Add a metric to this metric set.

Parameters:
  • metric (Metric | MetricFunction | type[Metric]) – The metric to add to the set.

  • label (str | None) – The label to use for the metric’s results. If unset, obtains from the metric.

  • default (float | None) – The default value to use in aggregates when a user does not have recommendations. If unset, obtains from the metric’s default attribute (if specified).

property metrics: list#

The list of metrics to compute.

Deprecated since version 2025.4: Access metrics through the accumulator interface instead.

compute(outputs, test)#

Deprecated alias for measure().

Deprecated since version 2025.1.1: Use measure() instead.

Parameters:
Return type:

RunAnalysisResult

measure(outputs, test)#

Measure a set of outputs against a set of test data.

Parameters:
Return type:

RunAnalysisResult