Changeset 111


Ignore:
Timestamp:
05/27/16 16:51:02 (8 years ago)
Author:
atrautsch
Message:

evalfix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/training/GPTraining.java

    r110 r111  
    479479            classifiers = new LinkedList<>(); 
    480480            for(int i=0; i < traindataSet.size(); i++) { 
    481                  
     481 
    482482                // candidates we get out of evaluation 
    483483                LinkedList<Classifier> candidates = new LinkedList<>(); 
    484484                 
    485                 // number of runs 
     485                // number of runs, yields the best of these 
    486486                for(int k=0; k < this.numberRuns; k++) { 
    487487                    Classifier classifier = new GPRun(); 
     
    497497                            // if type1 and type2 errors are < 0.5 we allow the model in the candidates 
    498498                            errors = this.evaluate((GPRun)classifier, traindataSet.get(j)); 
    499                             if((errors[0] < 0.5) && (errors[0] < 0.5)) { 
     499                            if((errors[0] < 0.5) && (errors[1] < 0.5)) { 
    500500                                candidates.add(classifier); 
    501501                            } 
     
    504504                } 
    505505                 
     506                 
    506507                // now after the evaluation we do a model selection where only one model remains for the given training data 
     508                // we select the model which is best on all evaluation data 
    507509                double smallest_error_count = Double.MAX_VALUE; 
    508510                double[] errors; 
    509511                Classifier best = null; 
    510512                for(int ii=0; ii < candidates.size(); ii++) { 
     513                    double[] errors_eval = {0.0, 0.0}; 
     514                     
     515                    // we add the errors the candidate makes over the evaldata 
    511516                    for(int j=0; j < traindataSet.size(); j++) { 
    512517                        if(j != i) { 
    513518                            errors = this.evaluate((GPRun)candidates.get(ii), traindataSet.get(j)); 
    514                              
    515                             if(errors[0]+errors[1] < smallest_error_count) { 
    516                                 best = candidates.get(ii); 
    517                             } 
     519                            errors_eval[0] += errors[0]; 
     520                            errors_eval[1] += errors[1]; 
    518521                        } 
    519522                    } 
    520                 } 
     523                     
     524                    // if the candidate made fewer errors it is now the best 
     525                    if(errors_eval[0] + errors_eval[1] < smallest_error_count) { 
     526                        best = candidates.get(ii); 
     527                        smallest_error_count = errors_eval[0] + errors_eval[1]; 
     528                    } 
     529                } 
     530                 
    521531                 
    522532                // now we have the best classifier for this training data 
    523533                classifiers.add(best); 
     534                 
     535                 
    524536            } 
    525537        } 
     
    635647                            // if type1 and type2 errors are < 0.5 we allow the model in the candidate list 
    636648                            errors = this.evaluate((GPRun)classifier, traindataSet.get(j)); 
    637                             if((errors[0] < 0.5) && (errors[0] < 0.5)) { 
     649                            if((errors[0] < 0.5) && (errors[1] < 0.5)) { 
    638650                                candidates.add(classifier); 
    639651                            } 
Note: See TracChangeset for help on using the changeset viewer.