Index: trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java
===================================================================
--- trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java	(revision 12)
+++ trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java	(revision 13)
@@ -26,7 +26,14 @@
 /**
  * ACHTUNG UNFERTIG
- *
  * 
- * Basically a copy of WekaClusterTraining2 with internal classes for the Fastmap and QuadTree implementations
+ * With WekaLocalTraining2 we do the following:
+ * 1) Run the Fastmap algorithm on all training data, let it calculate the 2 most significant 
+ *    dimensions and projections of each instance to these dimensions
+ * 2) With these 2 dimensions we span a QuadTree which gets recursively split on median(x) and median(y) values.
+ * 3) We cluster the QuadTree nodes together if they have similar density (50%)
+ * 4) We save the clusters and their training data
+ * 5) We train a Weka classifier for each cluster with the clusters training data
+ * 5) We classify single instances to a cluster and then classify them using the classifier of the cluster
+ * 
  */
 public class WekaLocalTraining2 extends WekaBaseTraining2 implements ITrainingStrategy {
@@ -34,9 +41,6 @@
 	private final TraindatasetCluster classifier = new TraindatasetCluster();
 	
-	// we do not need to keep them around
-	//private final QuadTree q = null;
-	//private final Fastmap f = null;
-	
 	// these values are set later when we have all the information we need
+	
 	/*Stopping rule for tree recursion (Math.sqrt(Instances)*/
 	public static double ALPHA = 0;
@@ -45,6 +49,4 @@
 	/*size of the complete set (used for density function)*/
 	public static int SIZE = 0;
-	
-	public static int MIN_INST = 10;
 	
 	// cluster
@@ -104,13 +106,11 @@
 		
 		/**
-		 * Because Fastmap saves only the image not the values of the attributes
-		 * we can not use it to classify single instances to values
-		 * 
-		 * TODO: mehr erklärung
-		 * TODO: class lavel filter raus
-		 * 
-		 * Finde die am nächsten liegende Instanz zur übergebenen
-		 * dann bestimme den cluster der instanz und führe dann den 
-		 * classifier des clusters aus
+		 * Because Fastmap saves only the image not the values of the attributes it used
+		 * we can not use it or the QuadTree to classify single instances to clusters.
+		 * 
+		 * To classify a single instance we measure the distance to all instances we have clustered and
+		 * use the cluster where the distance is minimal.
+		 * 
+		 * TODO: class attribute filter raus
 		 */
 		@Override
@@ -190,5 +190,5 @@
 			// 4. run fastmap for 2 dimensions on the distance matrix
 			Fastmap f = new Fastmap(2, dist);
-			f.calculate(2);
+			f.calculate();
 			double[][] X = f.getX();
 			
@@ -223,5 +223,5 @@
 		    SIZE = train.size();
 		    
-		    Console.traceln(Level.INFO, String.format("Generate QuadTree with "+ SIZE + " size, Alpha: "+ ALPHA+ ""));
+		    //Console.traceln(Level.INFO, String.format("Generate QuadTree with "+ SIZE + " size, Alpha: "+ ALPHA+ ""));
 		    
 		    // set the size and then split the tree recursively at the median value for x, y
@@ -232,16 +232,13 @@
 		    ArrayList<QuadTree> l = new ArrayList<QuadTree>(q.getList(q));
 		    
-		    // recursive grid clustering (tree pruning), the values are stored in cluster!
+		    // recursive grid clustering (tree pruning), the values are stored in cluster
 		    q.gridClustering(l);
-		    
-		    // after grid clustering we need to remove the clusters with < 2 * ALPHA instances
-		    
-		    // hier müssten wir sowas haben wie welche instanz in welchem cluster ist
-		    // oder wir iterieren durch die cluster und sammeln uns die instanzen daraus
+		 
+		    // wir iterieren durch die cluster und sammeln uns die instanzen daraus
 		    for(int i=0; i < cluster.size(); i++) {
 		    	ArrayList<QuadTreePayload<Instance>> current = cluster.get(i);
 		    	
 		    	// i is the clusternumber
-		    	// we only allow clusters with Instances > ALPHA
+		    	// we only allow clusters with Instances > ALPHA, other clusters are not considered!
 		    	if(current.size() > ALPHA) {
 			    	for(int j=0; j < current.size(); j++ ) {
@@ -290,8 +287,7 @@
 	}
 	
+	
 	/**
 	 * Fastmap implementation
-	 * 
-	 * TODO: only one place to pass dimension!
 	 * 
 	 * Faloutsos, C., & Lin, K. I. (1995). 
@@ -313,8 +309,12 @@
 		private int col = 0;
 		
+		/*number of dimensions we want*/
+		private int target_dims = 0;
+		
 		public Fastmap(int k, double[][] O) {
 			this.O = O;
-			
 			int N = O.length;
+			
+			this.target_dims = k;
 			
 			this.X = new double[N][k];
@@ -323,5 +323,5 @@
 		
 		/**
-		 * The distance function for eculidean distance
+		 * The distance function for euclidean distance
 		 * 
 		 * Acts according to equation 4 of the fastmap paper
@@ -395,7 +395,7 @@
 		 * @param dims dimensionality
 		 */
-		public void calculate(int dims) {
-			
-			for(int k=0; k <dims; k++) {
+		public void calculate() {
+			
+			for(int k=0; k <this.target_dims; k++) {
 				
 				// 2) choose pivot objects
@@ -436,4 +436,5 @@
 	}
 
+	
 	/**
 	 * QuadTree implementation
@@ -517,7 +518,6 @@
 		}
 		
-		
-		/**
-		 * Todo: DRY, median ist immer dasselbe
+		/**
+		 * TODO: DRY, median ist immer dasselbe
 		 *  
 		 * @return median for x
@@ -551,5 +551,4 @@
 		}
 		
-		
 		private double getMedianForY() {
 			double med_y =0 ;
@@ -580,5 +579,4 @@
 		}
 		
-		
 		/**
 		 * Reurns the number of instances in the payload
@@ -593,5 +591,4 @@
 			return number;
 		}
-		
 		
 		/**
@@ -678,7 +675,6 @@
 		}
 		
-		
 		/** 
-		 * Todo: evt. auslagern, eigentlich auch eher ne statische methode
+		 * TODO: evt. auslagern, eigentlich auch eher ne statische methode
 		 * 
 		 * @param q
@@ -704,5 +700,4 @@
 		}
 		
-		
 		/**
 		 * returns an list of childs sorted by density
@@ -732,5 +727,4 @@
 			}
 		}
-		
 		
 		/**
