public class TopNNDCGMetric extends ListOnlyTopNMetric<org.apache.commons.math3.stat.descriptive.moment.Mean>
Measure the nDCG of the top-N recommendations, using ratings as scores.
This metric is registered with the type name ndcg.
| Modifier and Type | Class and Description |
|---|---|
static class |
TopNNDCGMetric.Spec
Specification for configuring nDCG metrics.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_COLUMN |
| Constructor and Description |
|---|
TopNNDCGMetric()
Create an nDCG metric with log-2 discounting.
|
TopNNDCGMetric(Discount disc)
Create an nDCG metric with a default name.
|
TopNNDCGMetric(Discount disc,
java.lang.String name)
Construct a new nDCG Top-N metric.
|
TopNNDCGMetric(Discount disc,
java.lang.String name,
java.lang.String attr)
Construct a new nDCG Top-N metric.
|
TopNNDCGMetric(TopNNDCGMetric.Spec spec)
Construct a top-N nDCG metric from a spec.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.commons.math3.stat.descriptive.moment.Mean |
createContext(AlgorithmInstance algorithm,
DataSet dataSet,
RecommenderEngine engine)
Create the context for an experimental condition (algorithm/data set pair).
|
MetricResult |
getAggregateMeasurements(org.apache.commons.math3.stat.descriptive.moment.Mean context)
Get the aggregate results from an accumulator.
|
MetricResult |
measureUser(Recommender rec,
TestUser user,
int targetLength,
LongList recommendations,
org.apache.commons.math3.stat.descriptive.moment.Mean context)
Measurement method that only uses the recommend list.
|
measureUsergetAggregateColumnLabels, getColumnLabels, getRequiredRootspublic static final java.lang.String DEFAULT_COLUMN
public TopNNDCGMetric()
Create an nDCG metric with log-2 discounting.
public TopNNDCGMetric(Discount disc)
Create an nDCG metric with a default name.
disc - The discount to apply.public TopNNDCGMetric(TopNNDCGMetric.Spec spec)
Construct a top-N nDCG metric from a spec.
spec - The spec.public TopNNDCGMetric(Discount disc, java.lang.String name)
Construct a new nDCG Top-N metric.
disc - The discount to apply.name - The column name to use.public TopNNDCGMetric(Discount disc, java.lang.String name, java.lang.String attr)
Construct a new nDCG Top-N metric.
disc - The discount to apply.name - The column name to use.@Nullable public org.apache.commons.math3.stat.descriptive.moment.Mean createContext(AlgorithmInstance algorithm, DataSet dataSet, RecommenderEngine engine)
MetricCreate the context for an experimental condition (algorithm/data set pair). The default implementation returns null.
Note: Contexts must be thread-safe, in that multiple concurrent calls to the appropriate user-measurement function with the same context must be safe. This can be handled either by the context itself, or by the user-measurement function.
createContext in class Metric<org.apache.commons.math3.stat.descriptive.moment.Mean>algorithm - The algorithm.dataSet - The data set.engine - The LensKit recommender engine, if applicable. This can be null for an external algorithm that does not provide a LensKit recommender.null.@Nonnull public MetricResult getAggregateMeasurements(org.apache.commons.math3.stat.descriptive.moment.Mean context)
MetricGet the aggregate results from an accumulator. The default implementation returns MetricResult.empty().
getAggregateMeasurements in class Metric<org.apache.commons.math3.stat.descriptive.moment.Mean>context - The context for an experimental condition.@Nonnull public MetricResult measureUser(Recommender rec, TestUser user, int targetLength, LongList recommendations, org.apache.commons.math3.stat.descriptive.moment.Mean context)
ListOnlyTopNMetricMeasurement method that only uses the recommend list.
Thread Safety: This method may be called concurrently by multiple threads with the same recommender and context.
measureUser in class ListOnlyTopNMetric<org.apache.commons.math3.stat.descriptive.moment.Mean>rec - The recommender used to recommend for this user.user - The user.targetLength - The target list length.recommendations - The list of recommendations.context - The context.