Changeset 65 for trunk/CrossPare/src/de


Ignore:
Timestamp:
04/29/16 14:29:52 (9 years ago)
Author:
sherbold
Message:
  • added new interface ITestAwareTraining strategy to the framework to support trainers with knowledge of the test data. The implementation of such trainers must take care to not accidentally take the classification of the test data into account.
Location:
trunk/CrossPare/src/de/ugoe/cs/cpdp
Files:
1 added
3 edited

Legend:

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

    r45 r65  
    4242import de.ugoe.cs.cpdp.training.ISetWiseTestdataAwareTrainingStrategy; 
    4343import de.ugoe.cs.cpdp.training.ISetWiseTrainingStrategy; 
     44import de.ugoe.cs.cpdp.training.ITestAwareTrainingStrategy; 
    4445import de.ugoe.cs.cpdp.training.ITrainingStrategy; 
    4546import de.ugoe.cs.cpdp.versions.IVersionFilter; 
     
    139140     */ 
    140141    private List<ITrainingStrategy> trainers; 
     142     
     143    /** 
     144     * normal trainers, i.e., trainers that require the selected training data in a single data set 
     145     */ 
     146    private List<ITestAwareTrainingStrategy> testAwareTrainers; 
    141147 
    142148    /** 
     
    376382        return trainers; 
    377383    } 
     384     
     385    /** 
     386     * returns the test aware training algorithms 
     387     *  
     388     * @return normal training algorithms 
     389     */ 
     390    public List<ITestAwareTrainingStrategy> getTestAwareTrainers() { 
     391        return testAwareTrainers; 
     392    } 
    378393 
    379394    /** 
     
    524539                trainer.setParameter(attributes.getValue("param")); 
    525540                trainers.add(trainer); 
     541            } 
     542            else if (qName.equals("testawaretrainer")) { 
     543                final ITestAwareTrainingStrategy trainer = 
     544                    (ITestAwareTrainingStrategy) Class.forName("de.ugoe.cs.cpdp.training." + 
     545                                                          attributes.getValue("name")) 
     546                        .newInstance(); 
     547                trainer.setParameter(attributes.getValue("param")); 
     548                testAwareTrainers.add(trainer); 
    526549            } 
    527550            else if (qName.equals("eval")) { 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/execution/CrossProjectExperiment.java

    r44 r65  
    3333import de.ugoe.cs.cpdp.training.ISetWiseTestdataAwareTrainingStrategy; 
    3434import de.ugoe.cs.cpdp.training.ISetWiseTrainingStrategy; 
     35import de.ugoe.cs.cpdp.training.ITestAwareTrainingStrategy; 
    3536import de.ugoe.cs.cpdp.training.ITrainer; 
    3637import de.ugoe.cs.cpdp.training.ITrainingStrategy; 
     
    206207                    trainer.apply(traindata); 
    207208                } 
     209                for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 
     210                    Console.traceln(Level.FINE, String 
     211                        .format("[%s] [%02d/%02d] %s: applying trainer %s", 
     212                                config.getExperimentName(), versionCount, testVersionCount, 
     213                                testVersion.getVersion(), trainer.getName())); 
     214                    trainer.apply(testdata, traindata); 
     215                } 
    208216                File resultsDir = new File(config.getResultsPath()); 
    209217                if (!resultsDir.exists()) { 
     
    223231                    } 
    224232                    for (ITrainingStrategy trainer : config.getTrainers()) { 
     233                        allTrainers.add(trainer); 
     234                    } 
     235                    for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 
    225236                        allTrainers.add(trainer); 
    226237                    } 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/execution/RelaxedCrossProjectExperiment.java

    r44 r65  
    3333import de.ugoe.cs.cpdp.training.ISetWiseTestdataAwareTrainingStrategy; 
    3434import de.ugoe.cs.cpdp.training.ISetWiseTrainingStrategy; 
     35import de.ugoe.cs.cpdp.training.ITestAwareTrainingStrategy; 
    3536import de.ugoe.cs.cpdp.training.ITrainer; 
    3637import de.ugoe.cs.cpdp.training.ITrainingStrategy; 
     
    211212                    trainer.apply(traindata); 
    212213                } 
     214                for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 
     215                    Console.traceln(Level.FINE, String 
     216                        .format("[%s] [%02d/%02d] %s: applying trainer %s", 
     217                                config.getExperimentName(), versionCount, testVersionCount, 
     218                                testVersion.getVersion(), trainer.getName())); 
     219                    trainer.apply(testdata, traindata); 
     220                } 
    213221                File resultsDir = new File(config.getResultsPath()); 
    214222                if (!resultsDir.exists()) { 
     
    224232                        allTrainers.add(setwiseTrainer); 
    225233                    } 
     234                    for (ISetWiseTestdataAwareTrainingStrategy setwiseTrainer : config.getSetWiseTestdataAwareTrainers()) { 
     235                        allTrainers.add(setwiseTrainer); 
     236                    } 
    226237                    for (ITrainingStrategy trainer : config.getTrainers()) { 
     238                        allTrainers.add(trainer); 
     239                    } 
     240                    for (ITestAwareTrainingStrategy trainer : config.getTestAwareTrainers()) { 
    227241                        allTrainers.add(trainer); 
    228242                    } 
Note: See TracChangeset for help on using the changeset viewer.