Forwarding this to DKPro Lab, as the problem seem to be occurring there.
- Johannes
Von:
dkpro-...@googlegroups.com [mailto:
dkpro-...@googlegroups.com] Im Auftrag von Martin Wunderlich
Gesendet: Donnerstag, 23. Juli 2015 10:03
An: Tobias Horsmann
Cc: dkpro-tc-dev
Betreff: Re: [dkpro-tc-dev] Question on SaveModelWekaBatchTask
Thanks a lot, Tobias, for the comments. I tried to implement 4) yesterday (getting the tasks from the results of getTasks()), but at that stage getTasks() returns an empty list, strangely enough.
Here is the code:
String experimentName = „MyExperiment";
ExperimentTrainTest batch = new ExperimentTrainTest(experimentName,
WekaClassificationAdapter.class, getPreprocessing());
batch.setParameterSpace(pSpace);
batch.setExecutionPolicy(policy);
batch.addReport(BatchTrainTestReport.class);
batch.addReport(BatchRuntimeReport.class);
Set<Task> tasks = batch.getTasks();
MetaInfoTask meta = getMetaTask(tasks);
ExtractFeaturesTask fe = getFeatureExtractionTask(tasks);
ModelSerializationTask saveModelTask = new ModelSerializationTask();
File outputDir = (new File(outputfolder + experimentName + "/")).getAbsoluteFile();
String type = saveModelTask.getType() + "-" + experimentName;
saveModelTask.setType(type);
saveModelTask.setOutputFolder(outputDir);
saveModelTask.addImport(metaTask, MetaInfoTask.META_KEY);
saveModelTask.addImport(featuresTrainTask, ExtractFeaturesTask.OUTPUT_KEY, Constants.TEST_TASK_INPUT_KEY_TRAINING_DATA);
batch.addTask(saveModelTask);
...
public static ExtractFeaturesTask getFeatureExtractionTask(Set<Task> tasks) {
for(Task task : tasks)
if(task instanceof ExtractFeaturesTask)
return (ExtractFeaturesTask) task;
return null;
}
public static MetaInfoTask getMetaTask(Set<Task> tasks) {
for(Task task : tasks)
if(task instanceof MetaInfoTask)
return (MetaInfoTask) task;
return null;
}
I am not sure why the tasks list would be empty at that stage.
Cheers,
Martin
Am 23.07.2015 um 07:27 schrieb Tobias Horsmann <
tobias....@gmail.com>:
I would tend to take option 1
1)
I probably wouldnt create an abstract class, but rather the current "without" version as base class and then just add a subclass like "ExperimentTrainTestWithStore" (chose a name you like, just an idea)
With some minor changes to the TrainTest and CrossVal Task it should be possible to make a subclass that overrides a single method in the "without storing" base class where the model saving is done.
This would avoid that people who want only train-test would automatically get store, too.
Option 4 Is possible, but I think BatchTask is in DKPro Lab and not in TC and I would want to keep the changes locally.
--
You received this message because you are subscribed to the Google Groups "dkpro-tc-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
dkpro-tc-dev...@googlegroups.com.
To post to this group, send email to
dkpro-...@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.