package edu.ntnu.idi.goldfish;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.eval.IRStatistics;
import org.apache.mahout.cf.taste.eval.RecommenderEvaluator;
import org.apache.mahout.cf.taste.eval.RecommenderIRStatsEvaluator;
import org.apache.mahout.cf.taste.impl.eval.AverageAbsoluteDifferenceRecommenderEvaluator;
import org.apache.mahout.cf.taste.impl.eval.GenericRecommenderIRStatsEvaluator;
import org.apache.mahout.cf.taste.impl.eval.RMSRecommenderEvaluator;
import org.apache.mahout.cf.taste.model.DataModel;

public class Evaluator extends ArrayList<Recommender> {
	
	private static final long serialVersionUID = -167230272254792689L;
	DataModel dataModel;
	double trainingPercentage = 0.70;
	double testPercentage = 0.10;
	int topN = 10;
	double relevanceThreshold = GenericRecommenderIRStatsEvaluator.CHOOSE_THRESHOLD;
	
	public Evaluator(DataModel dataModel) {
		this.dataModel = dataModel;
	}
	
	public ArrayList<EvaluationResult> evaluateAll() throws IOException, TasteException {
		
		RecommenderEvaluator RMSE = new RMSRecommenderEvaluator();
		RecommenderEvaluator AAD = new AverageAbsoluteDifferenceRecommenderEvaluator();
		RecommenderIRStatsEvaluator irStats = new GenericRecommenderIRStatsEvaluator();
		
		ArrayList<EvaluationResult> results = new ArrayList<EvaluationResult>();
		
		double rmse;
		double aad;
		IRStatistics stats;
		for(Recommender recommender : this) {
			rmse = RMSE.evaluate(recommender.getBuilder(), null, dataModel, trainingPercentage, testPercentage);
			aad = AAD.evaluate(recommender.getBuilder(), null, dataModel, trainingPercentage, testPercentage);
			stats = irStats.evaluate(recommender.getBuilder(), null, dataModel, null, topN, relevanceThreshold, testPercentage);
			results.add(new EvaluationResult(recommender.toString(), rmse, aad, stats));
		}
		return results;
	}
}

@@ -743,111 +743,10 @@
 9L;%0A
+%0A
 %09
-DataModel dataModel;%0A%09double trainingPercentage = 0.70;%0A%09double testPercentage = 0.10;%0A%09int topN = 10;
 %0A%09do
@@ -848,60 +848,11 @@
 tor(
-DataModel dataModel) %7B%0A%09%09this.dataModel = dataModel;
+) %7B
 %0A%09%7D%0A
@@ -901,16 +901,75 @@
 uateAll(
+DataModel dataModel, double training, double test, int topN
 ) throws
@@ -1304,16 +1304,17 @@
 sult%3E();
+%09
 %0A%09%09%0A%09%09do
@@ -1479,34 +1479,14 @@
 ning
-Percentage, testPercentage
+, test
 );%0A%09
@@ -1561,34 +1561,14 @@
 ning
-Percentage, testPercentage
+, test
 );%0A%09
@@ -1677,18 +1677,8 @@
 test
-Percentage
 );%0A%09

Make Evaluator use dependency injection instead of having properties.