Package es.uam.eps.ir.relison.examples
Class AuxiliarMethods
java.lang.Object
es.uam.eps.ir.relison.examples.AuxiliarMethods
public class AuxiliarMethods
extends java.lang.Object
Class containing auxiliar methods for the Main functions.
-
Constructor Summary
Constructors Constructor Description AuxiliarMethods()
-
Method Summary
Modifier and Type Method Description static double
computeAndEvaluate(es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long> metric)
Computes a recommendation and evaluates it using nDCG metric.static java.util.Map<java.lang.String,java.lang.Double>
computeAndEvaluate(es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, java.util.Map<java.lang.String,es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long>> metrics)
Computes a recommendation and evaluates it using some metrics.static double
computeAndEvaluate(java.lang.String output, es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long> metric)
Computes a recommendation and evaluates it using nDCG metric.static java.util.Map<java.lang.String,java.lang.Double>
computeAndEvaluate(java.lang.String output, es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, java.util.Map<java.lang.String,es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long>> metrics)
Computes a recommendation and evaluates it using metrics.static void
printFile(java.lang.String output, java.util.List<java.util.Map<java.lang.String,java.lang.Double>> values, java.util.List<java.lang.String> ids)
Given a list of maps with the same keys, prints the values for all the keys.static void
printFile(java.lang.String output, java.util.List<java.util.Map<java.lang.String,java.lang.Double>> values, java.util.List<java.lang.String> ids, int maxLength)
Given a list of maps with the same keys, prints the values for all the keys.static void
printFile(java.lang.String output, java.util.Map<java.lang.String,java.lang.Double> first, java.util.Map<java.lang.String,java.lang.Double> second, java.lang.String firstId, java.lang.String secondId, int maxLength)
Given two maps with the same keys, generates a new file that prints the nDCG values for both.static java.util.Map<java.lang.String,java.lang.Object>
readYAML(java.lang.String file)
Reads a Yaml filestatic java.util.Map<java.lang.String,java.lang.Double>
writeAndEvaluate(java.lang.String output, java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<java.lang.Long,java.lang.Long>> recs, java.util.Map<java.lang.String,es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long>> metrics)
Writes and evaluates a recommendation.
-
Constructor Details
-
AuxiliarMethods
public AuxiliarMethods()
-
-
Method Details
-
readYAML
public static java.util.Map<java.lang.String,java.lang.Object> readYAML(java.lang.String file) throws java.io.IOExceptionReads a Yaml file- Parameters:
file
- the route to the file- Returns:
- a map containing the root of the Yaml file
- Throws:
java.io.IOException
- if something fails while reading the file.
-
computeAndEvaluate
public static double computeAndEvaluate(java.lang.String output, es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long> metric) throws java.io.IOExceptionComputes a recommendation and evaluates it using nDCG metric.- Parameters:
output
- Route of the file in which to store the recommendation.recommender
- The recommender to apply.runner
- The recommender runnermetric
- The metric.- Returns:
- the value of the metric.
- Throws:
java.io.IOException
- if something fails during the writing / reading of the recommendation file.
-
writeAndEvaluate
public static java.util.Map<java.lang.String,java.lang.Double> writeAndEvaluate(java.lang.String output, java.util.stream.Stream<es.uam.eps.ir.ranksys.core.Recommendation<java.lang.Long,java.lang.Long>> recs, java.util.Map<java.lang.String,es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long>> metrics) throws java.io.IOExceptionWrites and evaluates a recommendation.- Parameters:
output
- Route of the file in which to store the recommendation.recs
- the recommendations to read and evaluate.metrics
- the metrics.- Returns:
- the value of the metric.
- Throws:
java.io.IOException
- if something fails during the writing / reading of the recommendation file.
-
computeAndEvaluate
public static java.util.Map<java.lang.String,java.lang.Double> computeAndEvaluate(java.lang.String output, es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, java.util.Map<java.lang.String,es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long>> metrics) throws java.io.IOExceptionComputes a recommendation and evaluates it using metrics.- Parameters:
output
- Route of the file in which to store the recommendation.recommender
- The recommender to apply.runner
- The recommender runnermetrics
- The metrics to evaluate- Returns:
- the value of the metrics.
- Throws:
java.io.IOException
- if something fails during the writing / reading of the recommendation file.
-
computeAndEvaluate
public static double computeAndEvaluate(es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long> metric)Computes a recommendation and evaluates it using nDCG metric. It does not write the recommendation.- Parameters:
recommender
- The recommender to apply.runner
- The recommender runner.metric
- The metric.- Returns:
- the value of the metric.
-
computeAndEvaluate
public static java.util.Map<java.lang.String,java.lang.Double> computeAndEvaluate(es.uam.eps.ir.ranksys.rec.Recommender<java.lang.Long,java.lang.Long> recommender, es.uam.eps.ir.ranksys.rec.runner.RecommenderRunner<java.lang.Long,java.lang.Long> runner, java.util.Map<java.lang.String,es.uam.eps.ir.ranksys.metrics.SystemMetric<java.lang.Long,java.lang.Long>> metrics)Computes a recommendation and evaluates it using some metrics. It does not write the recommendation.- Parameters:
recommender
- The recommender to apply.runner
- The recommender runner.metrics
- The metrics.- Returns:
- the value of the metrics.
-
printFile
public static void printFile(java.lang.String output, java.util.Map<java.lang.String,java.lang.Double> first, java.util.Map<java.lang.String,java.lang.Double> second, java.lang.String firstId, java.lang.String secondId, int maxLength)Given two maps with the same keys, generates a new file that prints the nDCG values for both.- Parameters:
output
- The output file.first
- the first map.second
- the second map.firstId
- identifier for the first map.secondId
- identifier for the second map.maxLength
- maximum length of the recommendation.
-
printFile
public static void printFile(java.lang.String output, java.util.List<java.util.Map<java.lang.String,java.lang.Double>> values, java.util.List<java.lang.String> ids, int maxLength)Given a list of maps with the same keys, prints the values for all the keys.- Parameters:
output
- The output file.values
- The list of maps containing the values.ids
- Identifiers for each map.maxLength
- maximum length of the recommendation.
-
printFile
public static void printFile(java.lang.String output, java.util.List<java.util.Map<java.lang.String,java.lang.Double>> values, java.util.List<java.lang.String> ids)Given a list of maps with the same keys, prints the values for all the keys.- Parameters:
output
- The output file.values
- The list of maps containing the values.ids
- Identifiers for each map.
-