Search in sources :

Example 1 with ID2OutcomeCombiner

use of org.dkpro.tc.ml.report.util.ID2OutcomeCombiner in project dkpro-tc by dkpro.

the class DeepLearningInnerBatchReport method execute.

@Override
public void execute() throws Exception {
    StorageService store = getContext().getStorageService();
    Properties prop = new Properties();
    List<File> id2outcomeFiles = new ArrayList<>();
    Set<String> ids = getTaskIdsFromMetaData(getSubtasks());
    for (String id : ids) {
        if (!TcTaskTypeUtil.isMachineLearningAdapterTask(store, id)) {
            continue;
        }
        Map<String, String> discriminatorsMap = store.retrieveBinary(id, Task.DISCRIMINATORS_KEY, new PropertiesAdapter()).getMap();
        File id2outcomeFile = store.locateKey(id, Constants.ID_OUTCOME_KEY);
        id2outcomeFiles.add(id2outcomeFile);
        for (Entry<String, String> e : discriminatorsMap.entrySet()) {
            String key = e.getKey();
            String value = e.getValue();
            prop.setProperty(key, value);
        }
    }
    String learningMode = getDiscriminator(store, ids, DIM_LEARNING_MODE);
    ID2OutcomeCombiner<String> aggregator = new ID2OutcomeCombiner<>(learningMode);
    for (File id2o : id2outcomeFiles) {
        aggregator.add(id2o, learningMode);
    }
    writeCombinedOutcomeReport(aggregator.generateId2OutcomeFile());
}
Also used : PropertiesAdapter(org.dkpro.lab.storage.impl.PropertiesAdapter) ArrayList(java.util.ArrayList) Properties(java.util.Properties) ID2OutcomeCombiner(org.dkpro.tc.ml.report.util.ID2OutcomeCombiner) File(java.io.File) StorageService(org.dkpro.lab.storage.StorageService)

Example 2 with ID2OutcomeCombiner

use of org.dkpro.tc.ml.report.util.ID2OutcomeCombiner in project dkpro-tc by dkpro.

the class Id2OutcomeAggregatorTest method testAggregatorSingleLabel.

@Test
public void testAggregatorSingleLabel() throws Exception {
    ID2OutcomeCombiner<String> aggregator = new ID2OutcomeCombiner<>(Constants.LM_SINGLE_LABEL);
    aggregator.add(new File("src/test/resources/id2outcome/combine/singleLabelID2outcome_1.txt"), Constants.LM_SINGLE_LABEL);
    aggregator.add(new File("src/test/resources/id2outcome/combine/singleLabelID2outcome_2.txt"), Constants.LM_SINGLE_LABEL);
    assertEquals(18, aggregator.generateId2OutcomeFile().split("\n").length);
}
Also used : ID2OutcomeCombiner(org.dkpro.tc.ml.report.util.ID2OutcomeCombiner) File(java.io.File) Test(org.junit.Test)

Example 3 with ID2OutcomeCombiner

use of org.dkpro.tc.ml.report.util.ID2OutcomeCombiner in project dkpro-tc by dkpro.

the class Id2OutcomeAggregatorTest method testAggregatorRegression.

@Test
public void testAggregatorRegression() throws Exception {
    ID2OutcomeCombiner<String> aggregator = new ID2OutcomeCombiner<>(Constants.LM_REGRESSION);
    aggregator.add(new File("src/test/resources/id2outcome/combine/regressionID2outcome_1.txt"), Constants.LM_REGRESSION);
    aggregator.add(new File("src/test/resources/id2outcome/combine/regressionID2outcome_2.txt"), Constants.LM_REGRESSION);
    assertEquals(8, aggregator.generateId2OutcomeFile().split("\n").length);
    System.out.println(aggregator.generateId2OutcomeFile());
}
Also used : ID2OutcomeCombiner(org.dkpro.tc.ml.report.util.ID2OutcomeCombiner) File(java.io.File) Test(org.junit.Test)

Example 4 with ID2OutcomeCombiner

use of org.dkpro.tc.ml.report.util.ID2OutcomeCombiner in project dkpro-tc by dkpro.

the class Id2OutcomeAggregatorTest method testAggregatorMultilabel.

@Test
public void testAggregatorMultilabel() throws Exception {
    ID2OutcomeCombiner<String> aggregator = new ID2OutcomeCombiner<>(Constants.LM_MULTI_LABEL);
    aggregator.add(new File("src/test/resources/id2outcome/combine/multiLabelId2outcome_1.txt"), Constants.LM_MULTI_LABEL);
    aggregator.add(new File("src/test/resources/id2outcome/combine/multiLabelId2outcome_2.txt"), Constants.LM_MULTI_LABEL);
    assertEquals(8, aggregator.generateId2OutcomeFile().split("\n").length);
}
Also used : ID2OutcomeCombiner(org.dkpro.tc.ml.report.util.ID2OutcomeCombiner) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)4 ID2OutcomeCombiner (org.dkpro.tc.ml.report.util.ID2OutcomeCombiner)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 StorageService (org.dkpro.lab.storage.StorageService)1 PropertiesAdapter (org.dkpro.lab.storage.impl.PropertiesAdapter)1