public class TopNPopularityMetric extends ListOnlyTopNMetric<TopNPopularityMetric.Context>
Metric that measures how popular the items in the TopN list are.
This metric is registered with the type name popularity
.
Modifier and Type | Class and Description |
---|---|
class |
TopNPopularityMetric.Context |
static class |
TopNPopularityMetric.PopResult |
Constructor and Description |
---|
TopNPopularityMetric() |
Modifier and Type | Method and Description |
---|---|
TopNPopularityMetric.Context |
createContext(AlgorithmInstance algorithm,
DataSet dataSet,
Recommender recommender)
Create the context for an experimental condition (algorithm/data set pair).
|
MetricResult |
getAggregateMeasurements(TopNPopularityMetric.Context context)
Get the aggregate results from an accumulator.
|
Set<Class<?>> |
getRequiredRoots()
Get the classes on which this metric depends.
|
MetricResult |
measureUser(TestUser user,
int targetLength,
LongList recs,
TopNPopularityMetric.Context context)
Measurement method that only uses the recommend list.
|
measureUser
getAggregateColumnLabels, getColumnLabels
public Set<Class<?>> getRequiredRoots()
Metric
Get the classes on which this metric depends. These will be added to the roots of each algorithm configuration.
getRequiredRoots
in class Metric<TopNPopularityMetric.Context>
@Nullable public TopNPopularityMetric.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<TopNPopularityMetric.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 measureUser(TestUser user, int targetLength, LongList recs, TopNPopularityMetric.Context context)
ListOnlyTopNMetric
Measurement method that only uses the recommend list.
measureUser
in class ListOnlyTopNMetric<TopNPopularityMetric.Context>
user
- The user.targetLength
- The target list length.recs
- The list of recommendations.context
- The context.@Nonnull public MetricResult getAggregateMeasurements(TopNPopularityMetric.Context context)
Metric
Get the aggregate results from an accumulator. The default implementation returns MetricResult.empty()
.
getAggregateMeasurements
in class Metric<TopNPopularityMetric.Context>
context
- The context for an experimental condition.