Index: in/trunk/model-sites-dev/mars/WekaApplyArousalModel.java
===================================================================
--- /main/trunk/model-sites-dev/mars/WekaApplyArousalModel.java	(revision 34779)
+++ 	(revision )
@@ -1,220 +1,0 @@
-//import java.util.Random;
-
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.FileReader;
-import java.io.FileWriter;
-
-import weka.core.converters.ConverterUtils.DataSource;
-import weka.core.Attribute;
-import weka.core.Instance;
-import weka.core.Instances;
-import weka.core.SerializationHelper;
-
-import weka.filters.Filter;
-import weka.filters.unsupervised.attribute.Remove;
-
-import weka.classifiers.Classifier;
-
-
-// Based on:
-//   https://waikato.github.io/weka-wiki/use_weka_in_your_java_code/
-
-class WekaApplyArousalModel
-{
-    public final static String AROUSAL_ATTRIBUTE_NAME = "arousal_sample_26500ms";
-    public final static String VALANCE_ATTRIBUTE_NAME = "valance_sample_26500ms";
-
-    public final static String PREDICT_ATTRIBUTE_NAME = "arousal_sample_26500ms";
-    
-
-    public static Instances applyFilter(Instances data_instances,String additional_remove)
-    {
-	String remove_option_args = ("-R 425,458-466"); // remove ordinal attributes
-	if (additional_remove != null) {
-	    // top up, e.g. '472' representing valance in ground-truth files
-	    remove_option_args += "," + additional_remove;
-	}
-
-
-	Instances filtered_data_instances = null;
-	try {
-	    String[] filter_options = weka.core.Utils.splitOptions(remove_option_args); // remove ordinal attributes and 'valance'
-	    Remove filter_remove = new Remove();
-	    filter_remove.setOptions(filter_options);
-	    filter_remove.setInputFormat(data_instances);
-	    filtered_data_instances = Filter.useFilter(data_instances, filter_remove);
-	}
-	catch (Exception e) {
-	    e.printStackTrace();
-	    System.exit(1);
-	}
-	
-	return filtered_data_instances;	
-    }
-
-
-    
-    public static void checkDatasetInstancesCompatible(Instances new_instances)
-    {
-
-	final String gt_datasource_filename = "collect/deam/etc/deam-essentia-features-arousal-valence.arff";
-
-	try {
-	    DataSource gt_data_source = new DataSource(gt_datasource_filename);
-	    Instances gt_instances = gt_data_source.getDataSet();
-	    gt_instances = applyFilter(gt_instances,"472"); // top up with removing 'valance'
-	    
-	    gt_instances.setClassIndex(gt_instances.numAttributes() - 1);
-
-	    String equal_header_message = gt_instances.equalHeadersMsg(new_instances);
-	    
-	    if (equal_header_message != null) {
-		System.err.println("Headers to datasets were not equal!");
-		System.err.println(equal_header_message);
-		System.exit(1);
-	    }
-	}
-	catch (Exception e) {
-	    e.printStackTrace();
-	    System.exit(1);
-	}
-
-    }
-    
-    public static void main(String[] args)
-    {
-	if (args.length != 3) {
-	    System.err.println("Error: incorrect number of command-line arguments");
-	    System.err.println("Usage: trained-model.{model|ser} unclassified-data.{arff|csv} classified-data.{arff|csv}");
-	    System.exit(1);
-	}
-		
-	String classifier_input_filename        = args[0];
-	String unclassified_data_input_filename = args[1];
-	String classified_data_output_filename  = args[2];
-
-        System.out.println("Loading Weka saved Classifier: " + classifier_input_filename);
-
-	try {
-	    FileInputStream fis = new FileInputStream(classifier_input_filename);	
-	    BufferedInputStream bis= new BufferedInputStream(fis);
-	    Classifier classifier = (Classifier)SerializationHelper.read(bis);
-
-	    //
-	    // Load in unlabeled data
-	    //
-	    
-	    System.out.println("Loading unlabeled instances: " + unclassified_data_input_filename);
-
-	    //FileReader fr = new FileReader(unclassified_data_input_filename);
-	    //BufferedReader br = new BufferedReader(fr);
-	    //Instances unlabeled_instances = new Instances(br);
-	    //br.close();
-
-	    DataSource data_source = new DataSource(unclassified_data_input_filename);
-	    Instances unlabeled_instances = data_source.getDataSet();
-
-	    // Work out if we're dealing with a ground-truth ARFF file or not
-	    // (i.e. already has the desired attribute)
-
-	    Instances groundtruth_instances = null;	    
-	    Attribute predict_attribute = unlabeled_instances.attribute(PREDICT_ATTRIBUTE_NAME);
-	    
-	    if (predict_attribute == null) {
-
-		unlabeled_instances = applyFilter(unlabeled_instances,null); // no additional top-up to remove		
-		int num_attributes = unlabeled_instances.numAttributes();
-
-		Attribute arousal_attribute = new Attribute(AROUSAL_ATTRIBUTE_NAME);
-		unlabeled_instances.insertAttributeAt(arousal_attribute,num_attributes);
-		num_attributes++;
-		
-		//Attribute valance_attribute = new Attribute(VALANCE_ATTRIBUTE_NAME);
-		//unlabeled_instances.insertAttributeAt(valance_attribute,num_attributes);
-		//num_attributes++;
-
-		//predict_attribute = new Attribute(PREDICT_ATTRIBUTE_NAME);
-		//unlabeled_instances.insertAttributeAt(predict_attribute,num_attributes);
-		//unlabeled_instances.setClassIndex(num_attributes);
-		//num_attributes++;
-
-		//predict_attribute = unlabeled_instances.attribute(PREDICT_ATTRIBUTE_NAME);
-		//unlabeled_instances.setClass(predict_attribute);
-
-		//unlabeled_instances.setClassIndex(num_attributes - 1);
-	    }
-	    else {
-		// Dealing with ground-truth data:
-		//   => already has 'arousal' attribute
-		//   => in fact has 'valance' attribute too, which we want to remove
-		
-		unlabeled_instances = applyFilter(unlabeled_instances,"472"); // top-up with removal of 'valance'
-		//unlabeled_instances.setClass(predict_attribute);
-		
-		// reference share this as 'groundtruth_instances' to trigger error calculation and output
-		groundtruth_instances = unlabeled_instances;
-	    }
-
-	    int num_attributes = unlabeled_instances.numAttributes();
-	    unlabeled_instances.setClassIndex(num_attributes - 1);
-	    
-	    checkDatasetInstancesCompatible(unlabeled_instances);
-	    
-	    // Set class attribute
-	    //unlabeled_instances.setClassIndex(gt_instances.numAttributes() - 2);
-
-
-	    // Create copy where the predictions are to be made
-	    Instances labeled_instances = new Instances(unlabeled_instances);
-
-	    //
-	    // Label instances
-	    //
-	    
-	    final int num_instances = unlabeled_instances.numInstances();	    
-	    for (int i=0; i<num_instances; i++) {
-		Instance unlabeled_instance = unlabeled_instances.instance(i);
-
-		System.out.print("Making prediction for: " + i + "/" + num_instances);
-		double classified_value = classifier.classifyInstance(unlabeled_instance);
-		labeled_instances.instance(i).setClassValue(classified_value);
-
-		String formatted_classified_value = String.format("% 06.3f", classified_value);
-		
-		System.out.print(" value = " + formatted_classified_value);
-		
-		if (groundtruth_instances != null) {
-		    Instance gt_instance = groundtruth_instances.instance(i);
-		    double gt_class_value = gt_instance.classValue();
-		    double error = Math.abs(classified_value - gt_class_value);
-
-		    String formatted_error = String.format("%.3f", error);
-		    System.out.print("  [error: " + formatted_error + "]");
-		}
-		System.out.println();
-	    }
-
-	    //
-	    // Save labeled data
-	    //
-	    
-	    System.out.println("Saving labeled instances: " + classified_data_output_filename);		
-	    FileWriter fw = new FileWriter(classified_data_output_filename);
-	    BufferedWriter bw = new BufferedWriter(fw);
-	    
-	    bw.write(labeled_instances.toString());
-	    bw.newLine();
-	    bw.flush();
-	    bw.close();
-		     
-	}
-	catch (Exception e) {
-	    e.printStackTrace();
-	}
-       
-    }
-}
Index: in/trunk/model-sites-dev/mars/WekaTrainArousalModel.java
===================================================================
--- /main/trunk/model-sites-dev/mars/WekaTrainArousalModel.java	(revision 34779)
+++ 	(revision )
@@ -1,88 +1,0 @@
-import java.util.Random;
-
-import weka.core.converters.ConverterUtils.DataSource;
-import weka.core.Instances;
- 
-import weka.filters.Filter;
-import weka.filters.unsupervised.attribute.Remove;
-
-import weka.classifiers.Evaluation;
-import weka.classifiers.trees.REPTree;
-
-// Based on:
-//   https://waikato.github.io/weka-wiki/use_weka_in_your_java_code/
-
-
-// Also, for a more direct command-line approach see
-//    https://waikato.github.io/weka-wiki/saving_and_loading_models/
-//
-// You save a trained classifier with the -d option (dumping), e.g.:
-//
-//   java weka.classifiers.trees.J48 -C 0.25 -M 2 -t /some/where/train.arff -d /other/place/j48.model
-//
-// And you can load it with -l and use it on a test set, e.g.:
-//
-//   java weka.classifiers.trees.J48 -l /other/place/j48.model -T /some/where/test.arff
-
-     
-class WekaTrainArousalModel
-{
-    // Scheme:       weka.classifiers.trees.REPTree -M 2 -V 0.001 -N 3 -S 1 -L -1 -I 0.0
-    // Relation:     deam-essentia-features-arousal-valence-weka.filters.unsupervised.attribute.Remove-R472-weka.filters.unsupervised.attribute.Remove-R458-466
-    // Instances:    1743
-    
-    public static void main(String[] args)
-    {
-	if (args.length != 2) {
-	    System.err.println("Error: incorrect number of command-line arguments");
-	    System.err.println("Usage: input_training_data.arff output-model.{model|ser}");
-	    System.exit(1);
-	}
-	String input_arff_filename = args[0];
-	String output_model_filename = args[1];
-	
-        System.out.println("Training on ARFF file: " + input_arff_filename);
-
-	try {
-	    DataSource data_source = new DataSource(input_arff_filename);
-	    Instances data_instances = data_source.getDataSet();
-
-	    // Filter out Valence
-	    //String[] filter_options = weka.core.Utils.splitOptions("-R 472");
-	    //String[] filter_options = weka.core.Utils.splitOptions("-R 472 -R 458-466");
-	    String[] filter_options = weka.core.Utils.splitOptions("-R 425,458-466,472"); // remove ordinal attributes and 'valance'
-	    Remove filter_remove = new Remove();
-	    filter_remove.setOptions(filter_options);
-	    filter_remove.setInputFormat(data_instances);
-	    Instances filtered_data_instances = Filter.useFilter(data_instances, filter_remove);
-
-	    // **** have removed R472, so class to predict is numAttributes()-1
-	    filtered_data_instances.setClassIndex(filtered_data_instances.numAttributes() - 1);
-	    
-
-	    // Build scheme/classifier
-	    REPTree classifier = new REPTree(); // scheme
-	    String[] reptree_options = weka.core.Utils.splitOptions("-M 2 -V 0.001 -N 3 -S 1 -L -1 -I 0.0");
-	    classifier.setOptions(reptree_options);
-
-	    classifier.buildClassifier(filtered_data_instances);
-	    System.out.println(classifier);
-
-
- 	    Evaluation eval = new Evaluation(filtered_data_instances);
- 	    Random rand = new Random(1);
- 	    int folds = 10;
- 	    eval.crossValidateModel(classifier, filtered_data_instances, folds, rand);
- 	    System.out.println(eval.toSummaryString());
-
-	    System.out.println("Saving REPTree classifier model as: " + output_model_filename);
-	    weka.core.SerializationHelper.write(output_model_filename, classifier);
-
-	     
-	}
-	catch (Exception e) {
-	    e.printStackTrace();
-	}
- 
-    }
-}
Index: /main/trunk/model-sites-dev/mars/src/java/WekaApplyArousalModel.java
===================================================================
--- /main/trunk/model-sites-dev/mars/src/java/WekaApplyArousalModel.java	(revision 34780)
+++ /main/trunk/model-sites-dev/mars/src/java/WekaApplyArousalModel.java	(revision 34780)
@@ -0,0 +1,220 @@
+//import java.util.Random;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileReader;
+import java.io.FileWriter;
+
+import weka.core.converters.ConverterUtils.DataSource;
+import weka.core.Attribute;
+import weka.core.Instance;
+import weka.core.Instances;
+import weka.core.SerializationHelper;
+
+import weka.filters.Filter;
+import weka.filters.unsupervised.attribute.Remove;
+
+import weka.classifiers.Classifier;
+
+
+// Based on:
+//   https://waikato.github.io/weka-wiki/use_weka_in_your_java_code/
+
+class WekaApplyArousalModel
+{
+    public final static String AROUSAL_ATTRIBUTE_NAME = "arousal_sample_26500ms";
+    public final static String VALANCE_ATTRIBUTE_NAME = "valance_sample_26500ms";
+
+    public final static String PREDICT_ATTRIBUTE_NAME = "arousal_sample_26500ms";
+    
+
+    public static Instances applyFilter(Instances data_instances,String additional_remove)
+    {
+	String remove_option_args = ("-R 425,458-466"); // remove ordinal attributes
+	if (additional_remove != null) {
+	    // top up, e.g. '472' representing valance in ground-truth files
+	    remove_option_args += "," + additional_remove;
+	}
+
+
+	Instances filtered_data_instances = null;
+	try {
+	    String[] filter_options = weka.core.Utils.splitOptions(remove_option_args); // remove ordinal attributes and 'valance'
+	    Remove filter_remove = new Remove();
+	    filter_remove.setOptions(filter_options);
+	    filter_remove.setInputFormat(data_instances);
+	    filtered_data_instances = Filter.useFilter(data_instances, filter_remove);
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	    System.exit(1);
+	}
+	
+	return filtered_data_instances;	
+    }
+
+
+    
+    public static void checkDatasetInstancesCompatible(Instances new_instances)
+    {
+
+	final String gt_datasource_filename = "collect/deam/etc/deam-essentia-features-arousal-valence.arff";
+
+	try {
+	    DataSource gt_data_source = new DataSource(gt_datasource_filename);
+	    Instances gt_instances = gt_data_source.getDataSet();
+	    gt_instances = applyFilter(gt_instances,"472"); // top up with removing 'valance'
+	    
+	    gt_instances.setClassIndex(gt_instances.numAttributes() - 1);
+
+	    String equal_header_message = gt_instances.equalHeadersMsg(new_instances);
+	    
+	    if (equal_header_message != null) {
+		System.err.println("Headers to datasets were not equal!");
+		System.err.println(equal_header_message);
+		System.exit(1);
+	    }
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	    System.exit(1);
+	}
+
+    }
+    
+    public static void main(String[] args)
+    {
+	if (args.length != 3) {
+	    System.err.println("Error: incorrect number of command-line arguments");
+	    System.err.println("Usage: trained-model.{model|ser} unclassified-data.{arff|csv} classified-data.{arff|csv}");
+	    System.exit(1);
+	}
+		
+	String classifier_input_filename        = args[0];
+	String unclassified_data_input_filename = args[1];
+	String classified_data_output_filename  = args[2];
+
+        System.out.println("Loading Weka saved Classifier: " + classifier_input_filename);
+
+	try {
+	    FileInputStream fis = new FileInputStream(classifier_input_filename);	
+	    BufferedInputStream bis= new BufferedInputStream(fis);
+	    Classifier classifier = (Classifier)SerializationHelper.read(bis);
+
+	    //
+	    // Load in unlabeled data
+	    //
+	    
+	    System.out.println("Loading unlabeled instances: " + unclassified_data_input_filename);
+
+	    //FileReader fr = new FileReader(unclassified_data_input_filename);
+	    //BufferedReader br = new BufferedReader(fr);
+	    //Instances unlabeled_instances = new Instances(br);
+	    //br.close();
+
+	    DataSource data_source = new DataSource(unclassified_data_input_filename);
+	    Instances unlabeled_instances = data_source.getDataSet();
+
+	    // Work out if we're dealing with a ground-truth ARFF file or not
+	    // (i.e. already has the desired attribute)
+
+	    Instances groundtruth_instances = null;	    
+	    Attribute predict_attribute = unlabeled_instances.attribute(PREDICT_ATTRIBUTE_NAME);
+	    
+	    if (predict_attribute == null) {
+
+		unlabeled_instances = applyFilter(unlabeled_instances,null); // no additional top-up to remove		
+		int num_attributes = unlabeled_instances.numAttributes();
+
+		Attribute arousal_attribute = new Attribute(AROUSAL_ATTRIBUTE_NAME);
+		unlabeled_instances.insertAttributeAt(arousal_attribute,num_attributes);
+		num_attributes++;
+		
+		//Attribute valance_attribute = new Attribute(VALANCE_ATTRIBUTE_NAME);
+		//unlabeled_instances.insertAttributeAt(valance_attribute,num_attributes);
+		//num_attributes++;
+
+		//predict_attribute = new Attribute(PREDICT_ATTRIBUTE_NAME);
+		//unlabeled_instances.insertAttributeAt(predict_attribute,num_attributes);
+		//unlabeled_instances.setClassIndex(num_attributes);
+		//num_attributes++;
+
+		//predict_attribute = unlabeled_instances.attribute(PREDICT_ATTRIBUTE_NAME);
+		//unlabeled_instances.setClass(predict_attribute);
+
+		//unlabeled_instances.setClassIndex(num_attributes - 1);
+	    }
+	    else {
+		// Dealing with ground-truth data:
+		//   => already has 'arousal' attribute
+		//   => in fact has 'valance' attribute too, which we want to remove
+		
+		unlabeled_instances = applyFilter(unlabeled_instances,"472"); // top-up with removal of 'valance'
+		//unlabeled_instances.setClass(predict_attribute);
+		
+		// reference share this as 'groundtruth_instances' to trigger error calculation and output
+		groundtruth_instances = unlabeled_instances;
+	    }
+
+	    int num_attributes = unlabeled_instances.numAttributes();
+	    unlabeled_instances.setClassIndex(num_attributes - 1);
+	    
+	    checkDatasetInstancesCompatible(unlabeled_instances);
+	    
+	    // Set class attribute
+	    //unlabeled_instances.setClassIndex(gt_instances.numAttributes() - 2);
+
+
+	    // Create copy where the predictions are to be made
+	    Instances labeled_instances = new Instances(unlabeled_instances);
+
+	    //
+	    // Label instances
+	    //
+	    
+	    final int num_instances = unlabeled_instances.numInstances();	    
+	    for (int i=0; i<num_instances; i++) {
+		Instance unlabeled_instance = unlabeled_instances.instance(i);
+
+		System.out.print("Making prediction for: " + i + "/" + num_instances);
+		double classified_value = classifier.classifyInstance(unlabeled_instance);
+		labeled_instances.instance(i).setClassValue(classified_value);
+
+		String formatted_classified_value = String.format("% 06.3f", classified_value);
+		
+		System.out.print(" value = " + formatted_classified_value);
+		
+		if (groundtruth_instances != null) {
+		    Instance gt_instance = groundtruth_instances.instance(i);
+		    double gt_class_value = gt_instance.classValue();
+		    double error = Math.abs(classified_value - gt_class_value);
+
+		    String formatted_error = String.format("%.3f", error);
+		    System.out.print("  [error: " + formatted_error + "]");
+		}
+		System.out.println();
+	    }
+
+	    //
+	    // Save labeled data
+	    //
+	    
+	    System.out.println("Saving labeled instances: " + classified_data_output_filename);		
+	    FileWriter fw = new FileWriter(classified_data_output_filename);
+	    BufferedWriter bw = new BufferedWriter(fw);
+	    
+	    bw.write(labeled_instances.toString());
+	    bw.newLine();
+	    bw.flush();
+	    bw.close();
+		     
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}
+       
+    }
+}
Index: /main/trunk/model-sites-dev/mars/src/java/WekaTrainArousalModel.java
===================================================================
--- /main/trunk/model-sites-dev/mars/src/java/WekaTrainArousalModel.java	(revision 34780)
+++ /main/trunk/model-sites-dev/mars/src/java/WekaTrainArousalModel.java	(revision 34780)
@@ -0,0 +1,88 @@
+import java.util.Random;
+
+import weka.core.converters.ConverterUtils.DataSource;
+import weka.core.Instances;
+ 
+import weka.filters.Filter;
+import weka.filters.unsupervised.attribute.Remove;
+
+import weka.classifiers.Evaluation;
+import weka.classifiers.trees.REPTree;
+
+// Based on:
+//   https://waikato.github.io/weka-wiki/use_weka_in_your_java_code/
+
+
+// Also, for a more direct command-line approach see
+//    https://waikato.github.io/weka-wiki/saving_and_loading_models/
+//
+// You save a trained classifier with the -d option (dumping), e.g.:
+//
+//   java weka.classifiers.trees.J48 -C 0.25 -M 2 -t /some/where/train.arff -d /other/place/j48.model
+//
+// And you can load it with -l and use it on a test set, e.g.:
+//
+//   java weka.classifiers.trees.J48 -l /other/place/j48.model -T /some/where/test.arff
+
+     
+class WekaTrainArousalModel
+{
+    // Scheme:       weka.classifiers.trees.REPTree -M 2 -V 0.001 -N 3 -S 1 -L -1 -I 0.0
+    // Relation:     deam-essentia-features-arousal-valence-weka.filters.unsupervised.attribute.Remove-R472-weka.filters.unsupervised.attribute.Remove-R458-466
+    // Instances:    1743
+    
+    public static void main(String[] args)
+    {
+	if (args.length != 2) {
+	    System.err.println("Error: incorrect number of command-line arguments");
+	    System.err.println("Usage: input_training_data.arff output-model.{model|ser}");
+	    System.exit(1);
+	}
+	String input_arff_filename = args[0];
+	String output_model_filename = args[1];
+	
+        System.out.println("Training on ARFF file: " + input_arff_filename);
+
+	try {
+	    DataSource data_source = new DataSource(input_arff_filename);
+	    Instances data_instances = data_source.getDataSet();
+
+	    // Filter out Valence
+	    //String[] filter_options = weka.core.Utils.splitOptions("-R 472");
+	    //String[] filter_options = weka.core.Utils.splitOptions("-R 472 -R 458-466");
+	    String[] filter_options = weka.core.Utils.splitOptions("-R 425,458-466,472"); // remove ordinal attributes and 'valance'
+	    Remove filter_remove = new Remove();
+	    filter_remove.setOptions(filter_options);
+	    filter_remove.setInputFormat(data_instances);
+	    Instances filtered_data_instances = Filter.useFilter(data_instances, filter_remove);
+
+	    // **** have removed R472, so class to predict is numAttributes()-1
+	    filtered_data_instances.setClassIndex(filtered_data_instances.numAttributes() - 1);
+	    
+
+	    // Build scheme/classifier
+	    REPTree classifier = new REPTree(); // scheme
+	    String[] reptree_options = weka.core.Utils.splitOptions("-M 2 -V 0.001 -N 3 -S 1 -L -1 -I 0.0");
+	    classifier.setOptions(reptree_options);
+
+	    classifier.buildClassifier(filtered_data_instances);
+	    System.out.println(classifier);
+
+
+ 	    Evaluation eval = new Evaluation(filtered_data_instances);
+ 	    Random rand = new Random(1);
+ 	    int folds = 10;
+ 	    eval.crossValidateModel(classifier, filtered_data_instances, folds, rand);
+ 	    System.out.println(eval.toSummaryString());
+
+	    System.out.println("Saving REPTree classifier model as: " + output_model_filename);
+	    weka.core.SerializationHelper.write(output_model_filename, classifier);
+
+	     
+	}
+	catch (Exception e) {
+	    e.printStackTrace();
+	}
+ 
+    }
+}
