package edu.ntnu.idi.goldfish;

import edu.ntnu.idi.goldfish.configurations.Config;
import edu.ntnu.idi.goldfish.configurations.Lynx;
import edu.ntnu.idi.goldfish.preprocessors.*;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

import static edu.ntnu.idi.goldfish.DataSet.*;

public class Main {

    public static DataSet set;
	
	// disable Mahout logging output
	static {
		 System.setProperty("org.apache.commons.logging.Log",
		 "org.apache.commons.logging.impl.NoOpLog");
	}

	public static void main(String[] args) throws Exception {
		List<Config> configurations = new ArrayList<>();
		ResultList results = new ResultList();

        Config baseLine = new Lynx()
                .set("name", "baseline")
                .set("model", yowBaseline.getModel())
                .set("average", 5);

        Config stat = new Lynx()
                .set("name", "stat")
                .set("model", yowImplicit.getModel())
                .set("predictionMethod", PreprocessorStat.PredictionMethod.LinearRegression)
                .set("preprocessor", PreprocessorStat.class)
                .set("average", 10);

        Config puddis = new Lynx()
                .set("name", "puddis")
                .set("model", yowSMImplicit.getModel())
                .set("preprocessor", PreprocessorPuddis.class)
                .set("average", 10);


        Config classifiers = new Lynx()
                .set("name", "classifier")
                .set("model", yowImplicit.getModel())
                .set("preprocessor", PreprocessorClassifier.class)
                .set("average", 10);

        Config clustering = new Lynx()
                .set("name", "clustering")
                .set("model", yowImplicit.getModel())
                .set("preprocessor", PreprocessorClustering.class);

        Config mlr = new Lynx()
                .set("name", "mlr")
                .set("model", yowImplicit.getModel())
                .set("numberOfIndependentVariables", 1)
                .set("preprocessor", PreprocessorMLR.class);


        configurations.add(baseLine);
        configurations.add(stat);
        configurations.add(puddis);
//        configurations.add(classifiers);
//        configurations.add(clustering);
//        configurations.add(mlr);

		StopWatch.start("total evaluation");
//        System.out.format("Starting evaluation of %d configurations (%d users, %d items) \n", configurations.size(), dbModel.getNumUsers(), dbModel.getNumItems());

        Evaluator.evaluate(configurations, results);
        results.setColumns("name", "average", "RMSE", "evalTime");

        results.print();
        System.out.println(StringUtils.repeat("=", 190));
//        results.printSummary();
        results.save();

//        System.out.format("Evaluated %d configurations (%d users, %d items) in %s \n", configurations.size(), dbModel.getNumUsers(), dbModel.getNumItems(), StopWatch.str("total evaluation"));
	}
}

@@ -217,16 +217,100 @@
 ngUtils;
+%0Aimport weka.classifiers.bayes.NaiveBayes;%0Aimport weka.classifiers.functions.SMOreg;
 %0A%0Aimport
@@ -331,16 +331,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -692,18 +692,25 @@
 ption %7B%0A
-%09%09
+%0A        
 List%3CCon
@@ -720,23 +720,16 @@
 %3E config
-uration
 s = new 
@@ -743,18 +743,24 @@
 st%3C%3E();%0A
-%09%09
+        
 ResultLi
@@ -1552,51 +1552,8 @@
 x()%0A
-                .set(%22name%22, %22classifier%22)%0A
     
@@ -1693,36 +1693,263 @@
 .set(%22average%22, 
-10);
+5000);%0A%0A        List%3CClass%3E classes = Arrays.asList(NaiveBayes.class, SMOreg.class);%0A        classes.stream().forEach(c -%3E%0A            configs.add(classifiers.clone().set(%22name%22, c.getSimpleName()).set(%22classifier%22, c))%0A        );%0A
 %0A%0A        Config
@@ -2376,24 +2376,26 @@
 R.class);%0A%0A%0A
+//
         conf
@@ -2420,16 +2420,18 @@
 eLine);%0A
+//
         
@@ -2456,16 +2456,18 @@
 (stat);%0A
+//
         
@@ -2490,26 +2490,24 @@
 dd(puddis);%0A
-//
         conf
@@ -2500,39 +2500,32 @@
 ;%0A        config
-uration
 s.add(classifier
@@ -2606,16 +2606,144 @@
 (mlr);%0A%0A
+        Columns columns = Columns.getPrintFormats(%22name%22, %22average%22, %22RMSE%22, %22evalTime%22);%0A        results.setColumns(columns);%0A%0A
 %09%09StopWa
@@ -2773,18 +2773,16 @@
 tion%22);%0A
-//
         
@@ -2840,37 +2840,16 @@
 urations
- (%25d users, %25d items)
  %5Cn%22, co
@@ -2848,39 +2848,32 @@
  %5Cn%22, config
-uration
 s.size()
 , dbModel.ge
@@ -2864,58 +2864,11 @@
 ze()
-, dbModel.getNumUsers(), dbModel.getNumItems()
 );%0A
-%0A
     
@@ -2896,23 +2896,16 @@
 e(config
-uration
 s, resul
@@ -2910,79 +2910,64 @@
 ults
-);%0A        results.setColumns(%22name%22, %22average%22, %22RMSE%22, %22evalTime%22
+, res -%3E System.out.println(res.toString(columns))
 );%0A%0A
+//
     
@@ -3083,35 +3083,9 @@
 ();%0A
-        results.save();%0A%0A//
+%0A
     
@@ -3138,29 +3138,8 @@
 ions
- (%25d users, %25d items)
  in 
@@ -3152,23 +3152,16 @@
 , config
-uration
 s.size()
@@ -3165,54 +3165,8 @@
 e(),
- dbModel.getNumUsers(), dbModel.getNumItems(),
  Sto
@@ -3198,13 +3198,41 @@
 ion%22));%0A
-%09
+        results.save();%0A%0A    
 %7D%0A%7D%0A

Modify configurations in Main