Changeset 111 for trunk/CrossPare/src/de/ugoe/cs/cpdp/training
- Timestamp:
- 05/27/16 16:51:02 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/GPTraining.java
r110 r111 479 479 classifiers = new LinkedList<>(); 480 480 for(int i=0; i < traindataSet.size(); i++) { 481 481 482 482 // candidates we get out of evaluation 483 483 LinkedList<Classifier> candidates = new LinkedList<>(); 484 484 485 // number of runs 485 // number of runs, yields the best of these 486 486 for(int k=0; k < this.numberRuns; k++) { 487 487 Classifier classifier = new GPRun(); … … 497 497 // if type1 and type2 errors are < 0.5 we allow the model in the candidates 498 498 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)) { 500 500 candidates.add(classifier); 501 501 } … … 504 504 } 505 505 506 506 507 // 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 507 509 double smallest_error_count = Double.MAX_VALUE; 508 510 double[] errors; 509 511 Classifier best = null; 510 512 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 511 516 for(int j=0; j < traindataSet.size(); j++) { 512 517 if(j != i) { 513 518 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]; 518 521 } 519 522 } 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 521 531 522 532 // now we have the best classifier for this training data 523 533 classifiers.add(best); 534 535 524 536 } 525 537 } … … 635 647 // if type1 and type2 errors are < 0.5 we allow the model in the candidate list 636 648 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)) { 638 650 candidates.add(classifier); 639 651 }
Note: See TracChangeset
for help on using the changeset viewer.