public class TopNMRRMetric extends ListOnlyTopNMetric<TopNMRRMetric.Context>
Compute the mean reciprocal rank.
This metric is registered with the type name mrr
. It has two configuration parameters:
suffix
goodItems
Modifier and Type | Class and Description |
---|---|
static class |
TopNMRRMetric.AggregateResult |
static class |
TopNMRRMetric.Context |
static class |
TopNMRRMetric.UserResult |
Constructor and Description |
---|
TopNMRRMetric()
Construct a new MRR metric using the user’s test items as good.
|
TopNMRRMetric(ItemSelector goodItems,
String sfx)
Construct a new recall and precision top n metric
|
TopNMRRMetric(PRMetricSpec spec)
Construct an MRR metric from a spec.
|
Modifier and Type | Method and Description |
---|---|
TopNMRRMetric.Context |
createContext(AlgorithmInstance algorithm,
DataSet dataSet,
Recommender recommender)
Create the context for an experimental condition (algorithm/data set pair).
|
MetricResult |
getAggregateMeasurements(TopNMRRMetric.Context context)
Get the aggregate results from an accumulator.
|
MetricResult |
measureUser(TestUser user,
int targetLength,
LongList recommendations,
TopNMRRMetric.Context context)
Measurement method that only uses the recommend list.
|
measureUser
getAggregateColumnLabels, getColumnLabels, getRequiredRoots
public TopNMRRMetric()
Construct a new MRR metric using the user’s test items as good.
public TopNMRRMetric(PRMetricSpec spec)
Construct an MRR metric from a spec.
spec
- The metric speclpublic TopNMRRMetric(ItemSelector goodItems, String sfx)
Construct a new recall and precision top n metric
goodItems
- The list of items to consider “true positives”, all other items will be treated as “false positives”.sfx
- A suffix to append to the metric.@Nullable public TopNMRRMetric.Context createContext(AlgorithmInstance algorithm, DataSet dataSet, Recommender recommender)
Metric
Create the context for an experimental condition (algorithm/data set pair). The default implementation returns null
.
createContext
in class Metric<TopNMRRMetric.Context>
algorithm
- The algorithm.dataSet
- The data set.recommender
- The LensKit recommender, if applicable. This can be null for an external algorithm that does not provide a LensKit recommender.null
.@Nonnull public MetricResult getAggregateMeasurements(TopNMRRMetric.Context context)
Metric
Get the aggregate results from an accumulator. The default implementation returns MetricResult.empty()
.
getAggregateMeasurements
in class Metric<TopNMRRMetric.Context>
context
- The context for an experimental condition.@Nonnull public MetricResult measureUser(TestUser user, int targetLength, LongList recommendations, TopNMRRMetric.Context context)
ListOnlyTopNMetric
Measurement method that only uses the recommend list.
measureUser
in class ListOnlyTopNMetric<TopNMRRMetric.Context>
user
- The user.targetLength
- The target list length.recommendations
- The list of recommendations.context
- The context.