@ SuppressWarnings ( "unchecked" ) public static void run ( final Properties properties ) throws IOException , ClassNotFoundException , IllegalAccessException , InstantiationException , InvocationTargetException , NoSuchMethodException { EvaluationStrategy . OUTPUT_FORMAT recFormat ; if ( properties . getProperty ( PREDICTION_FILE_FORMAT ) . equals ( EvaluationStrategy . OUTPUT_FORMAT . TRECEVAL . toString ( ) ) ) { recFormat = EvaluationStrategy . OUTPUT_FORMAT . TRECEVAL ; } else { recFormat = EvaluationStrategy . OUTPUT_FORMAT . SIMPLE ; } System . out . println ( "Parsing started: test file" ) ; File testFile = new File ( properties . getProperty ( TEST_FILE ) ) ; DataModelIF < Long , Long > testModel = new SimpleParser ( ) . parseData ( testFile ) ; System . out . println ( "Parsing finished: test file" ) ; File predictionsFolder = new File ( properties . getProperty ( PREDICTION_FOLDER ) ) ; String predictionsPrefix = properties . getProperty ( PREDICTION_PREFIX ) ; Set < String > predictionFiles = new HashSet <> ( ) ; getAllPredictionFiles ( predictionFiles , predictionsFolder , predictionsPrefix ) ; // read other parameters Boolean overwrite = Boolean . parseBoolean ( properties . getProperty ( OUTPUT_OVERWRITE , "false" ) ) ; Boolean doAppend = Boolean . parseBoolean ( properties . getProperty ( OUTPUT_APPEND , "true" ) ) ; Boolean perUser = Boolean . parseBoolean ( properties . getProperty ( METRIC_PER_USER , "false" ) ) ; int [ ] rankingCutoffs = EvaluationMetricRunner . getRankingCutoffs ( properties ) ; // process info for each result file File resultsFolder = new File ( properties . getProperty ( OUTPUT_FOLDER ) ) ; for ( String file : predictionFiles ) { File predictionFile = new File ( predictionsPrefix + file ) ; System . out . println ( "Parsing started: recommendation file" ) ; DataModelIF < Long , Long > predictions ; switch ( recFormat ) { case SIMPLE : predictions = new SimpleParser ( ) . parseData ( predictionFile ) ; break ; case TRECEVAL : predictions = new TrecEvalParser ( ) . parseData ( predictionFile ) ; break ; default : throw new AssertionError ( ) ; } System . out . println ( "Parsing finished: recommendation file" ) ; File resultsFile = new File ( resultsFolder , "eval" + "__" + predictionFile . getName ( ) ) ; // get metrics for ( EvaluationMetric < Long > metric : instantiateEvaluationMetrics ( properties , predictions , testModel ) ) { // generate output EvaluationMetricRunner . generateOutput ( testModel , rankingCutoffs , metric , metric . getClass ( ) . getSimpleName ( ) , perUser , resultsFile , overwrite , doAppend ) ; } } }
Runs multiple evaluation metrics .