lenskit.metrics.RunAnalysis#

class lenskit.metrics.RunAnalysis(*metrics)#

Bases: object

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

Parameters:

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

__init__(*metrics)#
Parameters:

metrics (Metric)

Methods

__init__(*metrics)

add_metric(metric[, label, default])

Add a metric to this metric set.

compute(outputs, test)

Attributes

metrics

The list of metrics to compute.

metrics: list[MetricWrapper]#

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), or 0.0.