Ignore:
Timestamp:
10/16/14 10:37:01 (10 years ago)
Author:
atrautsch
Message:

Update wegen Speicherverbrauch, Debug Output auskommentiert.

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  
    6767                private EM clusterer = null; 
    6868 
    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;  
    7171                 
    7272                 
     
    115115                                int cnum = clusterer.clusterInstance(clusterInstance); 
    116116                                 
     117                                //Console.traceln(Level.INFO, String.format("instance is in cluster: " + cnum)); 
     118                                                 
    117119                                // 2. classify testata instance to the classifier 
    118120                                ret = cclassifier.get(cnum).classifyInstance(classInstance); 
     
    141143                        // 3. cluster data 
    142144                        //Console.traceln(Level.INFO, String.format("starting clustering")); 
     145                         
     146                        cclassifier = new HashMap<Integer, Classifier>(); 
     147                        ctraindata = new HashMap<Integer, Instances>(); 
    143148                         
    144149                        // use standard params for now 
     
    173178                        } 
    174179                         
     180                        // Debug output 
     181                        //Console.traceln(Level.INFO, String.format("number of clusters: " + clusterer.numberOfClusters())); 
     182                         
    175183                        // train one classifier per cluster, we get the clusternumber from the traindata 
    176184                        Iterator<Integer> clusternumber = ctraindata.keySet().iterator(); 
     
    180188                                cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber)); 
    181189                                 
    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")); 
    183191                        } 
    184192                } 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/training/WekaLocalTraining2.java

    r17 r19  
    7070                 
    7171                /* classifier per cluster */ 
    72                 private HashMap<Integer, Classifier> cclassifier = new HashMap<Integer, Classifier>(); 
     72                private HashMap<Integer, Classifier> cclassifier; 
    7373                 
    7474                /* instances per cluster */ 
    75                 private HashMap<Integer, Instances> ctraindata = new HashMap<Integer, Instances>();  
     75                private HashMap<Integer, Instances> ctraindata;  
    7676                 
    7777                /* 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; 
    7979                 
    8080                /* 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; 
    8282 
    8383                /* holds the sizes of the cluster multiple "boxes" per cluster */ 
     
    144144                                Fastmap FMAP = new Fastmap(2); 
    145145                                EuclideanDistance dist = new EuclideanDistance(traindata); 
    146                                  
    147146                                 
    148147                                // we set our pivot indices [x=0,y=1][dimension] 
     
    234233                            */ 
    235234                                 
    236                                 // TODO: can we be in more cluster than one? 
    237235                                // now we iterate over all clusters (well, boxes of sizes per cluster really) and save the number of the  
    238236                                // cluster in which we are 
     
    244242                                         
    245243                                        // 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 
    247245                                        for ( int box=0; box < this.csize.get(cnumber).size(); box++ ) {  
    248246                                                Double[][] current = this.csize.get(cnumber).get(box); 
     
    256254                                 
    257255                                // 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                                //} 
    263261 
    264262                                // now it can happen that we dont find a cluster because we deleted it previously (too few instances) 
     
    306304                        this.show_biggest = true; 
    307305                         
     306                        cclassifier = new HashMap<Integer, Classifier>(); 
     307                        ctraindata = new HashMap<Integer, Instances>(); 
     308                        cpivots = new HashMap<Integer, Instance>(); 
     309                        cpivotindices = new int[2][2]; 
    308310                         
    309311                        // 1. copy traindata 
     
    339341                         
    340342                        double[][] X = FMAP.getX(); 
     343                        distmat = new double[0][0]; 
     344                        System.gc(); 
    341345                         
    342346                        // quadtree payload generation 
    343347                        ArrayList<QuadTreePayload<Instance>> qtp = new ArrayList<QuadTreePayload<Instance>>(); 
    344348                     
    345                         // die max und min brauchen wir für die größenangaben der sektoren 
     349                        // we need these for the sizes of the quadrants 
    346350                        double[] big = {0,0}; 
    347351                        double[] small = {9999999,99999999}; 
     
    365369                    } 
    366370                     
    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]+")")); 
    368372                     
    369373                    // 5. generate quadtree 
     
    410414                         
    411415                        // here we keep things we need later on 
    412                         // QuadTree sizes for later use 
     416                        // QuadTree sizes for later use (matching new instances) 
    413417                        this.csize = new HashMap<Integer, ArrayList<Double[][]>>(QuadTree.csize); 
    414418                 
     
    436440                        Iterator<Integer> clusternumber = ctraindata.keySet().iterator(); 
    437441                        //cclassifier.clear(); 
     442                         
     443                        //int traindata_count = 0; 
    438444                        while ( clusternumber.hasNext() ) { 
    439445                                cnumber = clusternumber.next(); 
     
    441447                                cclassifier.get(cnumber).buildClassifier(ctraindata.get(cnumber)); 
    442448                                //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)); 
    447455                } 
    448456        } 
Note: See TracChangeset for help on using the changeset viewer.