lenskit.metrics.predict.MAE#

class lenskit.metrics.predict.MAE(missing_scores='error', missing_truth='error')#

Bases: PredictMetric

Compute MAE (mean absolute error). This is computed as:

\[\sum_{r_{ui} \in R} \left|r_{ui} - s(i|u)\right|\]

This metric does not do any fallbacks; if you want to compute MAE with fallback predictions (e.g. usign a bias model when a collaborative filter cannot predict), generate predictions with FallbackScorer.

Stability:
Caller (see Stability Levels).
Parameters:
measure_list(predictions, test=None, /)#

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:

tuple[float, int]

extract_list_metrics(data)#

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

Returns:

  • A float for simple metrics

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

  • None if no per-list metrics are available

Parameters:

data (tuple[float, int])

create_accumulator()#

Creaet an accumulator to aggregate per-list measurements into summary metrics.

Each result from measure_list() is passed to Accumulator.add().