Search in sources :

Example 56 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class BatchTaskTest method testUnresolvable.

@Test(expected = RuntimeException.class)
public void testUnresolvable() throws Exception {
    Dimension<String> dim = Dimension.create("param", "1", "2", "3");
    ParameterSpace pSpace = new ParameterSpace(dim);
    Task task1 = new ExecutableTaskBase() {

        @Discriminator
        private String param;

        @Override
        public void execute(TaskContext aContext) throws Exception {
        // Nothing to do
        }
    };
    Task task2 = new ExecutableTaskBase() {

        @Discriminator
        private String param;

        @Override
        public void execute(TaskContext aContext) throws Exception {
        // Nothing to do
        }
    };
    task2.addImport(task1, "DUMMY");
    task1.addImport(task2, "DUMMY");
    DefaultBatchTask batchTask = new DefaultBatchTask();
    batchTask.setParameterSpace(pSpace);
    batchTask.addTask(task1);
    batchTask.addTask(task2);
    Lab.getInstance().run(batchTask);
}
Also used : Task(org.dkpro.lab.task.Task) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) TaskContext(org.dkpro.lab.engine.TaskContext) ParameterSpace(org.dkpro.lab.task.ParameterSpace) ExecutableTaskBase(org.dkpro.lab.task.impl.ExecutableTaskBase) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Example 57 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class DiscriminatorTest method testMap.

@Test
public void testMap() throws Exception {
    Map<String, String> map1 = new HashMap<String, String>();
    map1.put("A", "89zsöoibca");
    map1.put("243jh1g45", "09z2#3ROj 	2r!]9832");
    Map<String, String> map2 = new HashMap<String, String>();
    map2.put("!&(B§V  §= ", "ü 8z9^2g3f9	xy");
    map2.put("!&§$ Ü!§$%ø⁄ª¨", "!$§ 240324 #");
    Dimension<Map<String, String>> dimMap = Dimension.create("map", map1, map2);
    ParameterSpace pSpace = new ParameterSpace(dimMap);
    DefaultBatchTask batch = new DefaultBatchTask();
    batch.setParameterSpace(pSpace);
    batch.addTask(new MapDiscriminatorTask());
    Lab.getInstance().run(batch);
}
Also used : HashMap(java.util.HashMap) ParameterSpace(org.dkpro.lab.task.ParameterSpace) HashMap(java.util.HashMap) Map(java.util.Map) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Example 58 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class DiscriminatorTest method testName.

@Test
public void testName() throws Exception {
    Dimension<String> dimValues = Dimension.create("val", "1");
    DefaultBatchTask batch = new DefaultBatchTask();
    batch.setParameterSpace(new ParameterSpace(dimValues));
    batch.addTask(new NameDiscriminatorTask());
    Lab.getInstance().run(batch);
}
Also used : ParameterSpace(org.dkpro.lab.task.ParameterSpace) DefaultBatchTask(org.dkpro.lab.task.impl.DefaultBatchTask) Test(org.junit.Test)

Example 59 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class FoldDimensionBundleTest method testFileFold.

@Test
public void testFileFold() {
    Dimension<String> baseData = Dimension.create("base", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
    FoldDimensionBundle<String> foldBundle = new FoldDimensionBundle<String>("fold", baseData, 3);
    String expected = "0 - [1, 4, 7, 10] [2, 5, 8, 3, 6, 9]\n" + "1 - [2, 5, 8] [1, 4, 7, 10, 3, 6, 9]\n" + "2 - [3, 6, 9] [1, 4, 7, 10, 2, 5, 8]\n";
    StringBuilder actual = new StringBuilder();
    int n = 0;
    ParameterSpace pSpace = new ParameterSpace(foldBundle);
    for (Map<String, Object> config : pSpace) {
        actual.append(String.format("%d - %s %s\n", n, config.get("fold_validation"), config.get("fold_training")));
        n++;
    }
    assertEquals(3, n);
    assertEquals(3, pSpace.getStepCount());
    assertEquals(expected, actual.toString());
}
Also used : FoldDimensionBundle(org.dkpro.lab.task.impl.FoldDimensionBundle) ParameterSpace(org.dkpro.lab.task.ParameterSpace) Test(org.junit.Test)

Example 60 with ParameterSpace

use of org.dkpro.lab.task.ParameterSpace in project dkpro-lab by dkpro.

the class FoldDimensionBundleTest method testSimpleFold.

@Test
public void testSimpleFold() {
    Dimension<String> baseData = Dimension.create("base", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
    FoldDimensionBundle<String> foldBundle = new FoldDimensionBundle<String>("fold", baseData, 3);
    String expected = "0 - [1, 4, 7, 10] [2, 5, 8, 3, 6, 9]\n" + "1 - [2, 5, 8] [1, 4, 7, 10, 3, 6, 9]\n" + "2 - [3, 6, 9] [1, 4, 7, 10, 2, 5, 8]\n";
    StringBuilder actual = new StringBuilder();
    int n = 0;
    ParameterSpace pSpace = new ParameterSpace(foldBundle);
    for (Map<String, Object> config : pSpace) {
        actual.append(String.format("%d - %s %s\n", n, config.get("fold_validation"), config.get("fold_training")));
        n++;
    }
    assertEquals(3, n);
    assertEquals(3, pSpace.getStepCount());
    assertEquals(expected, actual.toString());
}
Also used : FoldDimensionBundle(org.dkpro.lab.task.impl.FoldDimensionBundle) ParameterSpace(org.dkpro.lab.task.ParameterSpace) Test(org.junit.Test)

Aggregations

ParameterSpace (org.dkpro.lab.task.ParameterSpace)130 HashMap (java.util.HashMap)60 CollectionReaderDescription (org.apache.uima.collection.CollectionReaderDescription)51 Map (java.util.Map)45 Test (org.junit.Test)44 TcFeatureSet (org.dkpro.tc.api.features.TcFeatureSet)42 File (java.io.File)26 WekaAdapter (org.dkpro.tc.ml.weka.WekaAdapter)21 DefaultBatchTask (org.dkpro.lab.task.impl.DefaultBatchTask)12 ArrayList (java.util.ArrayList)10 LiblinearAdapter (org.dkpro.tc.ml.liblinear.LiblinearAdapter)9 NaiveBayes (weka.classifiers.bayes.NaiveBayes)9 TaskContext (org.dkpro.lab.engine.TaskContext)7 CrfSuiteAdapter (org.dkpro.tc.ml.crfsuite.CrfSuiteAdapter)7 LibsvmAdapter (org.dkpro.tc.ml.libsvm.LibsvmAdapter)7 List (java.util.List)6 XgboostAdapter (org.dkpro.tc.ml.xgboost.XgboostAdapter)6 FoldDimensionBundle (org.dkpro.lab.task.impl.FoldDimensionBundle)5 SMO (weka.classifiers.functions.SMO)5 Task (org.dkpro.lab.task.Task)4