Index: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaBaseTraining2.java
===================================================================
--- trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaBaseTraining2.java	(revision 19)
+++ trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaBaseTraining2.java	(revision 20)
@@ -5,8 +5,18 @@
 
 import de.ugoe.cs.util.console.Console;
+
 import weka.core.OptionHandler;
 import weka.classifiers.Classifier;
 import weka.classifiers.meta.CVParameterSelection;
 
+/**
+ * WekaBaseTraining2
+ * 
+ * Allows specification of the Weka classifier and its params in the XML experiment configuration.
+ * 
+ * Important conventions of the XML format: 
+ * Cross Validation params come always last and are prepended with -CVPARAM
+ * Example: <trainer name="WekaClusterTraining2" param="RandomForestLocal weka.classifiers.trees.RandomForest -CVPARAM I 5 25 5"/>
+ */
 public abstract class WekaBaseTraining2 implements WekaCompatibleTrainer {
 	
@@ -20,13 +30,13 @@
 		String[] params = parameters.split(" ");
 
-		// first is classifierName
+		// first part of the params is the classifierName (e.g. SMORBF)
 		classifierName = params[0];
 		
-		// all following parameters can be copied from weka!
+		// the following parameters can be copied from weka!
 		
-		// second param is classifierClassName
+		// second param is classifierClassName (e.g. weka.classifiers.functions.SMO)
 		classifierClassName = params[1];
 	
-		// rest are params to the specified classifier
+		// rest are params to the specified classifier (e.g. -K weka.classifiers.functions.supportVector.RBFKernel)
 		classifierParams = Arrays.copyOfRange(params, 2, params.length);
 		
@@ -46,5 +56,5 @@
 			Classifier obj = (Classifier) c.newInstance();
 			
-			// Filter -CVPARAM
+			// Filter out -CVPARAM, these are special because they do not belong to the Weka classifier class as parameters
 			String[] param = Arrays.copyOf(classifierParams, classifierParams.length);
 			String[] cvparam = {};
@@ -68,5 +78,5 @@
 			
 			// we have cross val params
-			// cant check on cvparam.length may not be initialized			
+			// cant check on cvparam.length here, it may not be initialized			
 			if(cv) {
 				final CVParameterSelection ps = new CVParameterSelection();
Index: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaClusterTraining2.java
===================================================================
--- trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaClusterTraining2.java	(revision 19)
+++ trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaClusterTraining2.java	(revision 20)
@@ -23,9 +23,11 @@
  * WekaClusterTraining2
  * 
- * 1. Cluster traindata
- * 2. for each cluster train a classifier with traindata from cluster
- * 3. match testdata instance to a cluster, then classify with classifier from the cluster
+ * Currently supports only EM Clustering.
  * 
- * XML config:
+ * 1. Cluster training data
+ * 2. for each cluster train a classifier with training data from cluster
+ * 3. match test data instance to a cluster, then classify with classifier from the cluster
+ * 
+ * XML configuration:
  * <!-- because of clustering -->
  * <preprocessor name="Normalization" param=""/>
@@ -33,7 +35,4 @@
  * <!-- cluster trainer -->
  * <trainer name="WekaClusterTraining2" param="NaiveBayes weka.classifiers.bayes.NaiveBayes" />
- * 
- * Questions:
- * - how do we configure the clustering params?
  */
 public class WekaClusterTraining2 extends WekaBaseTraining2 implements ITrainingStrategy {
@@ -45,5 +44,4 @@
 		return classifier;
 	}
-	
 	
 	@Override
@@ -71,5 +69,12 @@
 		
 		
-		
+		/**
+		 * Helper method that gives us a clean instance copy with 
+		 * the values of the instancelist of the first parameter. 
+		 * 
+		 * @param instancelist with attributes
+		 * @param instance with only values
+		 * @return copy of the instance
+		 */
 		private Instance createInstance(Instances instances, Instance instance) {
 			// attributes for feeding instance to classifier
@@ -96,13 +101,13 @@
 		}
 		
-		
 		@Override
 		public double classifyInstance(Instance instance) {
 			double ret = 0;
 			try {
+				// 1. copy the instance (keep the class attribute)
 				Instances traindata = ctraindata.get(0);
 				Instance classInstance = createInstance(traindata, instance);
 				
-				// remove class attribute before clustering
+				// 2. remove class attribute before clustering
 				Remove filter = new Remove();
 				filter.setAttributeIndices("" + (traindata.classIndex() + 1));
@@ -110,12 +115,11 @@
 				traindata = Filter.useFilter(traindata, filter);
 				
+				// 3. copy the instance (without the class attribute) for clustering
 				Instance clusterInstance = createInstance(traindata, instance);
 				
-				// 1. classify testdata instance to a cluster number
+				// 4. match instance without class attribute to a cluster number
 				int cnum = clusterer.clusterInstance(clusterInstance);
 				
-				//Console.traceln(Level.INFO, String.format("instance is in cluster: " + cnum));
-						
-				// 2. classify testata instance to the classifier
+				// 5. classify instance with class attribute to the classifier of that cluster number
 				ret = cclassifier.get(cnum).classifyInstance(classInstance);
 				
@@ -127,10 +131,8 @@
 		}
 
-		
-		
 		@Override
 		public void buildClassifier(Instances traindata) throws Exception {
 			
-			// 1. copy traindata
+			// 1. copy training data
 			Instances train = new Instances(traindata);
 			
@@ -141,33 +143,28 @@
 			train = Filter.useFilter(train, filter);
 			
-			// 3. cluster data
-			//Console.traceln(Level.INFO, String.format("starting clustering"));
-			
+			// new objects
 			cclassifier = new HashMap<Integer, Classifier>();
 			ctraindata = new HashMap<Integer, Instances>();
 			
+			// 3. cluster data
 			// use standard params for now
 			clusterer = new EM();
+			// we can set options like so:
 			//String[] params = {"-N", "100"};
 			//clusterer.setOptions(params);
+			
+			// set max num of clusters to train data size (although we do not want that)
+			clusterer.setMaximumNumberOfClusters(train.size());
+						
+			// build clusterer
 			clusterer.buildClusterer(train);
-			// set max num to traindata size
-			clusterer.setMaximumNumberOfClusters(train.size());
-			
-			// 4. get cluster membership of our traindata
-			//AddCluster cfilter = new AddCluster();
-			//cfilter.setClusterer(clusterer);
-			//cfilter.setInputFormat(train);
-			//Instances ctrain = Filter.useFilter(train, cfilter);
 			
 			Instances ctrain = new Instances(train);
 			
-			// get traindata per cluster
+			// get train data per cluster
 			int cnumber;
 			for ( int j=0; j < ctrain.numInstances(); j++ ) {
-				// get the cluster number from the attributes, subract 1 because if we clusterInstance we get 0-n, and this is 1-n
-				//cnumber = Integer.parseInt(ctrain.get(j).stringValue(ctrain.get(j).numAttributes()-1).replace("cluster", "")) - 1;
+				cnumber = clusterer.clusterInstance(ctrain.get(j));
 				
-				cnumber = clusterer.clusterInstance(ctrain.get(j));
 				// add training data to list of instances for this cluster number
 				if ( !ctraindata.containsKey(cnumber) ) {
@@ -178,8 +175,5 @@
 			}
 			
-			// Debug output
-			//Console.traceln(Level.INFO, String.format("number of clusters: " + clusterer.numberOfClusters()));
-			
-			// train one classifier per cluster, we get the clusternumber from the traindata
+			// train one classifier per cluster, we get the cluster number from the training data
 			Iterator<Integer> clusternumber = ctraindata.keySet().iterator();
 			while ( clusternumber.hasNext() ) {
@@ -188,5 +182,5 @@
 				cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber));
 				
-				//Console.traceln(Level.INFO, String.format("building classifier in cluster "+cnumber + " with " + ctraindata.get(cnumber).size() + " traindata instances"));
+				//Console.traceln(Level.INFO, String.format("classifier in cluster "+cnumber));
 			}
 		}
Index: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java
===================================================================
--- trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java	(revision 19)
+++ trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java	(revision 20)
@@ -84,7 +84,11 @@
 		private HashMap<Integer, ArrayList<Double[][]>> csize;
 		
+		/* debug vars */
+		@SuppressWarnings("unused")
 		private boolean show_biggest = true;
 		
+		@SuppressWarnings("unused")
 		private int CFOUND = 0;
+		@SuppressWarnings("unused")
 		private int CNOTFOUND = 0;
 		
@@ -260,5 +264,5 @@
 				//}
 
-				// now it can happen that we dont find a cluster because we deleted it previously (too few instances)
+				// now it can happen that we do not find a cluster because we deleted it previously (too few instances)
 				// or we get bigger distance measures from weka so that we are completely outside of our clusters.
 				// in these cases we just find the nearest cluster to our instance and use it for classification.
@@ -280,5 +284,5 @@
 				}
 				
-				// here we have the cluster where an instance has the minimum distance between itself the
+				// here we have the cluster where an instance has the minimum distance between itself and the
 				// instance we want to classify
 				// if we still have not found a cluster we exit because something is really wrong
@@ -436,5 +440,5 @@
 			*/
 			
-		    // train one classifier per cluster, we get the clusternumber from the traindata
+		    // train one classifier per cluster, we get the cluster number from the traindata
 		    int cnumber;
 			Iterator<Integer> clusternumber = ctraindata.keySet().iterator();
@@ -444,5 +448,5 @@
 			while ( clusternumber.hasNext() ) {
 				cnumber = clusternumber.next();
-				cclassifier.put(cnumber,setupClassifier()); // das hier ist der eigentliche trainer 
+				cclassifier.put(cnumber,setupClassifier());  // this is the classifier used for the cluster 
 				cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber));
 				//Console.traceln(Level.INFO, String.format("classifier in cluster "+cnumber));
Index: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaTraining2.java
===================================================================
--- trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaTraining2.java	(revision 19)
+++ trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaTraining2.java	(revision 20)
@@ -10,5 +10,5 @@
 
 /**
- * Programmatic WekaBaggingTraining
+ * Programmatic WekaTraining
  *
  * first parameter is Trainer Name.
