lenskit.metrics.bulk#
Attributes#
Classes#
Results of a bulk metric computation. |
|
Compute metrics over a collection of item lists composing a run. |
Module Contents#
- lenskit.metrics.bulk.K1#
- lenskit.metrics.bulk.K2#
- class lenskit.metrics.bulk.RunAnalysisResult(lmvs, gmvs, defaults)#
Results of a bulk metric computation.
Deprecated since version 2026.1: This class is deprecated in favor of directly using
MeasurementCollector.- Stability:
- Caller (see Stability Levels).
- Parameters:
lmvs (pandas.DataFrame)
gmvs (pandas.Series)
- global_metrics()#
Get the global metric scores. This is only the results of global metrics; it does not include aggregates of per-list metrics. For aggregates of per-list metrics, call
list_summary().- Return type:
- list_metrics(fill_missing=True)#
Get the per-list scores of the results. This is a data frame with one row per list (with the list key on the index), and one metric per column.
- Parameters:
fill_missing – If
True(the default), fills in missing values with each metric’s default value when available. PassFalseif you want to do analyses that need to treat missing values differently.- Return type:
- list_summary(*keys)#
Summary statistics for the per-list metrics. Each metric is on its own row, with columns reporting the following:
mean:The mean metric value.
median:The median metric value.
std:The (sample) standard deviation of the metric.
Additional columns are added based on other options. Missing metric values are filled with their defaults before computing statistics.
- Parameters:
keys (str) – Identifiers for different conditions that should be reported separately (grouping keys for the final result).
- Return type:
- merge_from(other)#
Merge another set of analysis results into this one.
- Parameters:
other (RunAnalysisResult)
- class lenskit.metrics.bulk.RunAnalysis(*metrics)#
Compute metrics over a collection of item lists composing a run.
This class now uses
MetricAccumulatorinternally to separate accumulation from looping, while maintaining the same external interface.Changed in version 2026.1: Global metric outputs from this class have changed column names in some cases, to simplify logic.
Deprecated since version 2026.1: This class is deprecated in favor of directly using
MeasurementCollector.- Parameters:
metrics (lenskit.metrics._base.Metric) – A list of metrics; you can also add them with
add_metric(), which provides more flexibility.- Stability:
- Caller (see Stability Levels).
- collector: lenskit.metrics.MeasurementCollector#
The measurement collector for this analysis.
- add_metric(metric, label=None, default=None)#
Add a metric to this metric set.
- Parameters:
metric (lenskit.metrics._base.Metric | lenskit.metrics._base.MetricFunction | type[lenskit.metrics._base.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
defaultattribute (if specified).
- compute(outputs, test)#
Deprecated alias for
measure().Deprecated since version 2025.1.1: Use
measure()instead.- Parameters:
outputs (lenskit.data.ItemListCollection[K1])
test (lenskit.data.ItemListCollection[K2])
- Return type:
- measure(outputs, test)#
Measure a set of outputs against a set of test data.
- Parameters:
outputs (lenskit.data.ItemListCollection[K1])
test (lenskit.data.ItemListCollection[K2])
- Return type:
Exported Aliases#
- class lenskit.metrics.bulk.ItemListCollection#
Re-exported alias for
lenskit.data.ItemListCollection.
- exception lenskit.metrics.bulk.DataWarning#
Re-exported alias for
lenskit.diagnostics.DataWarning.
- class lenskit.metrics.bulk.Metric#
Re-exported alias for
lenskit.metrics._base.Metric.
- class lenskit.metrics.bulk.MetricFunction#
Re-exported alias for
lenskit.metrics._base.MetricFunction.