public class NDCGPredictMetric extends AbstractMetric<MeanAccumulator,NDCGPredictMetric.Result,NDCGPredictMetric.Result>
This is a prediction evaluator that uses base-2 nDCG to evaluate recommender accuracy. The items are ordered by predicted preference and the nDCG is computed using the user's real rating as the gain for each item. Doing this only over the queried items, rather than in the general recommend condition, avoids penalizing recommenders for recommending items that would be better if the user had known about them and provided ratings (e.g., for doing their job).
nDCG is computed per-user and then averaged over all users.
Modifier and Type | Class and Description |
---|---|
static class |
NDCGPredictMetric.Result |
Constructor and Description |
---|
NDCGPredictMetric() |
Modifier and Type | Method and Description |
---|---|
MeanAccumulator |
createContext(Attributed algo,
TTDataSet ds,
Recommender rec)
Create the context for an experimental condition (algorithm/data set pair).
|
NDCGPredictMetric.Result |
doMeasureUser(TestUser user,
MeanAccumulator context)
Measure a user with typed results.
|
protected NDCGPredictMetric.Result |
getTypedResults(MeanAccumulator context)
Get the typed results from an accumulator.
|
close, getColumnLabels, getPrefix, getResults, getSuffix, getUserColumnLabels, measureUser
public MeanAccumulator createContext(Attributed algo, TTDataSet ds, Recommender rec)
Metric
algo
- The algorithm.ds
- The data set.rec
- The LensKit recommender, if applicable. This can be null for an external
algorithm that does not provide a LensKit recommender.Metric.measureUser(TestUser, Object)
. If
the metric does not accumulate any results, this method can return null
.public NDCGPredictMetric.Result doMeasureUser(TestUser user, MeanAccumulator context)
AbstractMetric
doMeasureUser
in class AbstractMetric<MeanAccumulator,NDCGPredictMetric.Result,NDCGPredictMetric.Result>
user
- The user to measure.context
- The context.null
to emit NAs for the user.protected NDCGPredictMetric.Result getTypedResults(MeanAccumulator context)
AbstractMetric
getTypedResults
in class AbstractMetric<MeanAccumulator,NDCGPredictMetric.Result,NDCGPredictMetric.Result>
context
- The context.null
to emit NAs.