public abstract class TopNMetric<X> extends Metric<X>
Base class for metrics that measure Top-N recommendations for users.
Modifier | Constructor and Description |
---|---|
protected |
TopNMetric(java.lang.Class<? extends TypedMetricResult> resType,
java.lang.Class<? extends TypedMetricResult> aggType)
Construct a new result metric.
|
protected |
TopNMetric(java.lang.Class<? extends TypedMetricResult> resType,
java.lang.Class<? extends TypedMetricResult> aggType,
java.lang.String suffix)
Construct a new result metric.
|
protected |
TopNMetric(java.util.List<java.lang.String> labels,
java.util.List<java.lang.String> aggLabels)
Construct a new result metric.
|
Modifier and Type | Method and Description |
---|---|
abstract MetricResult |
measureUser(Recommender rec,
TestUser user,
int targetLength,
ResultList recommendations,
X context)
Measure a single result.
|
createContext, getAggregateColumnLabels, getAggregateMeasurements, getColumnLabels, getRequiredRoots
protected TopNMetric(java.util.List<java.lang.String> labels, java.util.List<java.lang.String> aggLabels)
Construct a new result metric.
labels
- Column labels.aggLabels
- Aggregate column labels.protected TopNMetric(java.lang.Class<? extends TypedMetricResult> resType, java.lang.Class<? extends TypedMetricResult> aggType)
Construct a new result metric.
resType
- The result type for measuring results, or null
for no measurement.aggType
- The result type for aggregate measurements, or null
for no measurement.protected TopNMetric(java.lang.Class<? extends TypedMetricResult> resType, java.lang.Class<? extends TypedMetricResult> aggType, java.lang.String suffix)
Construct a new result metric.
resType
- The result type for measuring results, or null
for no measurement.aggType
- The result type for aggregate measurements, or null
for no measurement.suffix
- Suffix to apply to names.@Nonnull public abstract MetricResult measureUser(Recommender rec, TestUser user, int targetLength, ResultList recommendations, X context)
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.
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.