public class TopNEntropyMetric extends ListOnlyTopNMetric<TopNEntropyMetric.Context>
Metric that measures the entropy of the top N recommendations across all users.
This tell us essentially how large of a range of the items your recommender is covering. It does not return any per-user results.
Small values indicate that the algorithm tends to prefer a small number of items which it recomments to all users. Large values mean that the algorithm recommends many different items (to many different users)
The smallest value happens when the topN list is the same for all users (which would give an entropy of roughly log_2(N)). The largest value happens when each item is recommended the same number of times (for an entropy of roughly log_2(number of items)).
This metric is registered with the type name entropy
.
Modifier and Type | Class and Description |
---|---|
static class |
TopNEntropyMetric.Context |
static class |
TopNEntropyMetric.EntropyResult |
Constructor and Description |
---|
TopNEntropyMetric()
Construct a new length metric.
|
Modifier and Type | Method and Description |
---|---|
TopNEntropyMetric.Context |
createContext(AlgorithmInstance algorithm,
DataSet dataSet,
Recommender recommender)
Create the context for an experimental condition (algorithm/data set pair).
|
MetricResult |
getAggregateMeasurements(TopNEntropyMetric.Context context)
Get the aggregate results from an accumulator.
|
MetricResult |
measureUser(TestUser user,
int targetLength,
LongList recommendations,
TopNEntropyMetric.Context context)
Measurement method that only uses the recommend list.
|
measureUser
getAggregateColumnLabels, getColumnLabels, getRequiredRoots
@Nonnull public MetricResult measureUser(TestUser user, int targetLength, LongList recommendations, TopNEntropyMetric.Context context)
ListOnlyTopNMetric
Measurement method that only uses the recommend list.
measureUser
in class ListOnlyTopNMetric<TopNEntropyMetric.Context>
user
- The user.targetLength
- The target list length.recommendations
- The list of recommendations.context
- The context.@Nullable public TopNEntropyMetric.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<TopNEntropyMetric.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(TopNEntropyMetric.Context context)
Metric
Get the aggregate results from an accumulator. The default implementation returns MetricResult.empty()
.
getAggregateMeasurements
in class Metric<TopNEntropyMetric.Context>
context
- The context for an experimental condition.