public abstract class ListOnlyTopNMetric<X> extends TopNMetric<X>
Intermediate class for top-N metrics that only depend on the list of recommended items, not their details. Metrics extending this class will implement the measureUser(Recommender, TestUser, int, LongList, Object)
method instead of measureUser(Recommender, TestUser, int, ResultList, Object)
. The recommend eval task uses this subclass to improve efficiency when results are not used in the evaluation.
Modifier | Constructor and Description |
---|---|
protected |
ListOnlyTopNMetric(java.lang.Class<? extends TypedMetricResult> resType,
java.lang.Class<? extends TypedMetricResult> aggType) |
protected |
ListOnlyTopNMetric(java.lang.Class<? extends TypedMetricResult> resType,
java.lang.Class<? extends TypedMetricResult> aggType,
java.lang.String suffix) |
protected |
ListOnlyTopNMetric(java.util.List<java.lang.String> labels,
java.util.List<java.lang.String> aggLabels) |
Modifier and Type | Method and Description |
---|---|
abstract MetricResult |
measureUser(Recommender rec,
TestUser user,
int targetLength,
LongList recommendations,
X context)
Measurement method that only uses the recommend list.
|
MetricResult |
measureUser(Recommender rec,
TestUser user,
int targetLength,
ResultList recommendations,
X context)
Measure a single result.
|
createContext, getAggregateColumnLabels, getAggregateMeasurements, getColumnLabels, getRequiredRoots
protected ListOnlyTopNMetric(java.util.List<java.lang.String> labels, java.util.List<java.lang.String> aggLabels)
protected ListOnlyTopNMetric(java.lang.Class<? extends TypedMetricResult> resType, java.lang.Class<? extends TypedMetricResult> aggType)
protected ListOnlyTopNMetric(java.lang.Class<? extends TypedMetricResult> resType, java.lang.Class<? extends TypedMetricResult> aggType, java.lang.String suffix)
@Nonnull public final MetricResult measureUser(Recommender rec, TestUser user, int targetLength, ResultList recommendations, X context)
TopNMetric
Measure a single result. The result may come from either prediction or recommendation.
Thread Safety: This method may be called concurrently by multiple threads with the same recommender and context.
measureUser
in class TopNMetric<X>
rec
- The recommender used to recommend for this user.user
- The user’s test data.targetLength
- The intended length of the recommendation list.recommendations
- The user’s recommendations.@Nonnull public abstract MetricResult measureUser(Recommender rec, TestUser user, int targetLength, LongList recommendations, X context)
Measurement method that only uses the recommend list.
Thread Safety: This method may be called concurrently by multiple threads with the same recommender and context.
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.