Changeset 19 for trunk/CrossPare/src/de
- Timestamp:
- 10/16/14 10:37:01 (10 years ago)
- Location:
- trunk/CrossPare/src/de/ugoe/cs/cpdp/training
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaClusterTraining2.java
r2 r19 67 67 private EM clusterer = null; 68 68 69 private HashMap<Integer, Classifier> cclassifier = new HashMap<Integer, Classifier>();70 private HashMap<Integer, Instances> ctraindata = new HashMap<Integer, Instances>();69 private HashMap<Integer, Classifier> cclassifier; 70 private HashMap<Integer, Instances> ctraindata; 71 71 72 72 … … 115 115 int cnum = clusterer.clusterInstance(clusterInstance); 116 116 117 //Console.traceln(Level.INFO, String.format("instance is in cluster: " + cnum)); 118 117 119 // 2. classify testata instance to the classifier 118 120 ret = cclassifier.get(cnum).classifyInstance(classInstance); … … 141 143 // 3. cluster data 142 144 //Console.traceln(Level.INFO, String.format("starting clustering")); 145 146 cclassifier = new HashMap<Integer, Classifier>(); 147 ctraindata = new HashMap<Integer, Instances>(); 143 148 144 149 // use standard params for now … … 173 178 } 174 179 180 // Debug output 181 //Console.traceln(Level.INFO, String.format("number of clusters: " + clusterer.numberOfClusters())); 182 175 183 // train one classifier per cluster, we get the clusternumber from the traindata 176 184 Iterator<Integer> clusternumber = ctraindata.keySet().iterator(); … … 180 188 cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber)); 181 189 182 //Console.traceln(Level.INFO, String.format(" classifier in cluster "+cnumber));190 //Console.traceln(Level.INFO, String.format("building classifier in cluster "+cnumber + " with " + ctraindata.get(cnumber).size() + " traindata instances")); 183 191 } 184 192 } -
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java
r17 r19 70 70 71 71 /* classifier per cluster */ 72 private HashMap<Integer, Classifier> cclassifier = new HashMap<Integer, Classifier>();72 private HashMap<Integer, Classifier> cclassifier; 73 73 74 74 /* instances per cluster */ 75 private HashMap<Integer, Instances> ctraindata = new HashMap<Integer, Instances>();75 private HashMap<Integer, Instances> ctraindata; 76 76 77 77 /* holds the instances and indices of the pivot objects of the Fastmap calculation in buildClassifier*/ 78 private HashMap<Integer, Instance> cpivots = new HashMap<Integer, Instance>();78 private HashMap<Integer, Instance> cpivots; 79 79 80 80 /* holds the indices of the pivot objects for x,y and the dimension [x,y][dimension]*/ 81 private int[][] cpivotindices = new int[2][2];81 private int[][] cpivotindices; 82 82 83 83 /* holds the sizes of the cluster multiple "boxes" per cluster */ … … 144 144 Fastmap FMAP = new Fastmap(2); 145 145 EuclideanDistance dist = new EuclideanDistance(traindata); 146 147 146 148 147 // we set our pivot indices [x=0,y=1][dimension] … … 234 233 */ 235 234 236 // TODO: can we be in more cluster than one?237 235 // now we iterate over all clusters (well, boxes of sizes per cluster really) and save the number of the 238 236 // cluster in which we are … … 244 242 245 243 // now iterate over the boxes of the cluster and hope we find one (cluster could have been removed) 246 // or we are too far away from any cluster 244 // or we are too far away from any cluster because of the fastmap calculation with the initial pivot objects 247 245 for ( int box=0; box < this.csize.get(cnumber).size(); box++ ) { 248 246 Double[][] current = this.csize.get(cnumber).get(box); … … 256 254 257 255 // we want to count how often we are really inside a cluster 258 if ( found_cnumber == -1 ) {259 CNOTFOUND += 1;260 }else {261 CFOUND += 1;262 }256 //if ( found_cnumber == -1 ) { 257 // CNOTFOUND += 1; 258 //}else { 259 // CFOUND += 1; 260 //} 263 261 264 262 // now it can happen that we dont find a cluster because we deleted it previously (too few instances) … … 306 304 this.show_biggest = true; 307 305 306 cclassifier = new HashMap<Integer, Classifier>(); 307 ctraindata = new HashMap<Integer, Instances>(); 308 cpivots = new HashMap<Integer, Instance>(); 309 cpivotindices = new int[2][2]; 308 310 309 311 // 1. copy traindata … … 339 341 340 342 double[][] X = FMAP.getX(); 343 distmat = new double[0][0]; 344 System.gc(); 341 345 342 346 // quadtree payload generation 343 347 ArrayList<QuadTreePayload<Instance>> qtp = new ArrayList<QuadTreePayload<Instance>>(); 344 348 345 // die max und min brauchen wir für die größenangaben der sektoren349 // we need these for the sizes of the quadrants 346 350 double[] big = {0,0}; 347 351 double[] small = {9999999,99999999}; … … 365 369 } 366 370 367 Console.traceln(Level.INFO, String.format("size for cluster ("+small[0]+","+small[1]+") - ("+big[0]+","+big[1]+")"));371 //Console.traceln(Level.INFO, String.format("size for cluster ("+small[0]+","+small[1]+") - ("+big[0]+","+big[1]+")")); 368 372 369 373 // 5. generate quadtree … … 410 414 411 415 // here we keep things we need later on 412 // QuadTree sizes for later use 416 // QuadTree sizes for later use (matching new instances) 413 417 this.csize = new HashMap<Integer, ArrayList<Double[][]>>(QuadTree.csize); 414 418 … … 436 440 Iterator<Integer> clusternumber = ctraindata.keySet().iterator(); 437 441 //cclassifier.clear(); 442 443 //int traindata_count = 0; 438 444 while ( clusternumber.hasNext() ) { 439 445 cnumber = clusternumber.next(); … … 441 447 cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber)); 442 448 //Console.traceln(Level.INFO, String.format("classifier in cluster "+cnumber)); 443 //Console.traceln(Level.INFO, String.format("" + ctraindata.get(cnumber).size() + " instances in cluster "+cnumber)); 444 } 445 446 //Console.traceln(Level.INFO, String.format("num clusters: "+cclassifier.size())); 449 //traindata_count += ctraindata.get(cnumber).size(); 450 //Console.traceln(Level.INFO, String.format("building classifier in cluster "+cnumber +" with "+ ctraindata.get(cnumber).size() +" traindata instances")); 451 } 452 453 // add all traindata 454 //Console.traceln(Level.INFO, String.format("traindata in all clusters: " + traindata_count)); 447 455 } 448 456 }
Note: See TracChangeset
for help on using the changeset viewer.