File file = new File(aContext.getStorageLocation(DUMMY_KEY, AccessMode.READWRITE) .getPath()); file.mkdir();
@Override public CollectionReaderDescription getCollectionReaderDescription(TaskContext aContext) throws ResourceInitializationException, IOException { // TrainTest setup: input files are set as imports if (filesRoot == null || files_training == null) { File root = aContext.getStorageLocation(INPUT_KEY, AccessMode.READONLY); Collection<File> files = FileUtils.listFiles(root, new String[] { "bin" }, true); return createReaderDescription(BinaryCasReader.class, BinaryCasReader.PARAM_PATTERNS, files); } // CV setup: filesRoot and files_atrining have to be set as dimension else { return createReaderDescription(BinaryCasReader.class, BinaryCasReader.PARAM_PATTERNS, files_training); } }
@Override public CollectionReaderDescription getCollectionReaderDescription(TaskContext aContext) throws ResourceInitializationException, IOException { // TrainTest setup: input files are set as imports if (filesRoot == null) { File root = aContext.getStorageLocation(INPUT_KEY, AccessMode.READONLY); Collection<File> files = FileUtils.listFiles(root, new String[] { "bin" }, true); return createReaderDescription(BinaryCasReader.class, BinaryCasReader.PARAM_PATTERNS, files); } // CV setup: filesRoot and files_atrining have to be set as dimension else { Collection<String> files = isTesting ? files_validation : files_training; return createReaderDescription(BinaryCasReader.class, BinaryCasReader.PARAM_PATTERNS, files); } } }
@Override public void execute() throws Exception { File storage = getContext().getStorageLocation(TestTask.OUTPUT_KEY, AccessMode.READONLY); Properties props = new Properties(); File evaluationFile = new File(storage.getAbsolutePath() + "/" + TestTask.EVALUATION_DATA_KEY); weka.classifiers.Evaluation eval = (weka.classifiers.Evaluation) SerializationHelper .read(evaluationFile.getAbsolutePath()); HashMap<String, Double> m = new HashMap<String, Double>(); m.put(CORRELATION, eval.correlationCoefficient()); m.put(MEAN_ABSOLUTE_ERROR, eval.meanAbsoluteError()); m.put(RELATIVE_ABSOLUTE_ERROR, eval.relativeAbsoluteError()); m.put(ROOT_MEAN_SQUARED_ERROR, eval.rootMeanSquaredError()); m.put(ROOT_RELATIVE_SQUARED_ERROR, eval.rootRelativeSquaredError()); for (String s : m.keySet()) { props.setProperty(s, m.get(s).toString()); } // Write out properties getContext().storeBinary(TestTask.RESULTS_KEY, new PropertiesAdapter(props)); } }
throws ResourceInitializationException, IOException File outputDir = aContext.getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE); File file = new File(aContext.getStorageLocation(META_KEY, AccessMode.READONLY), parameterKeyPairs.get(key)); parameters.addAll(Arrays.asList(key, file.getAbsolutePath()));
@Override public void execute() throws Exception { File storage = getContext().getStorageLocation(TestTask.OUTPUT_KEY, AccessMode.READONLY); File arff = new File(storage.getAbsolutePath() + "/" + TestTask.PREDICTIONS_KEY); Instances predictions = TaskUtils.getInstances(arff, TestTask.MULTILABEL); Properties props = generateProperties(predictions, TestTask.MULTILABEL); getContext().storeBinary(ID_OUTCOME_KEY, new PropertiesAdapter(props)); }
@Override public void execute(TaskContext aContext) throws Exception { File xmiPathRoot = aContext.getStorageLocation(PreprocessTask.OUTPUT_KEY_TRAIN, AccessMode.READONLY); Collection<File> files = FileUtils.listFiles(xmiPathRoot, new String[] { "bin" }, true); String[] fileNames = new String[files.size()]; int i = 0; for (File f : files) { // adding file paths, not names fileNames[i] = f.getAbsolutePath(); i++; } Arrays.sort(fileNames); if (numFolds == Constants.LEAVE_ONE_OUT) { numFolds = fileNames.length; } // don't change any names!! FoldDimensionBundle<String> foldDim = getFoldDim(fileNames); Dimension<File> filesRootDim = Dimension.create("filesRoot", xmiPathRoot); ParameterSpace pSpace = new ParameterSpace(foldDim, filesRootDim); setParameterSpace(pSpace); super.execute(aContext); } };
File file = new File(aContext.getStorageLocation(META_KEY, AccessMode.READONLY) .getPath()); file.mkdir(); File file = new File(aContext.getStorageLocation(META_KEY, AccessMode.READONLY), parameterKeyPairs.get(key)); parameters.addAll(Arrays.asList(key, file.getAbsolutePath()));
@Override public void execute(TaskContext aContext) throws Exception { File xmiPathRoot = aContext.getStorageLocation(PreprocessTask.OUTPUT_KEY_TRAIN, AccessMode.READONLY); Collection<File> files = FileUtils.listFiles(xmiPathRoot, new String[] { "bin" }, true); String[] fileNames = new String[files.size()]; int i = 0; for (File f : files) { // adding file paths, not names fileNames[i] = f.getAbsolutePath(); i++; } Arrays.sort(fileNames); if (numFolds == Constants.LEAVE_ONE_OUT) { numFolds = fileNames.length; } // don't change any names!! FoldDimensionBundle<String> foldDim = new FoldDimensionBundle<String>("files", Dimension.create("", fileNames), numFolds); Dimension<File> filesRootDim = Dimension.create("filesRoot", xmiPathRoot); ParameterSpace pSpace = new ParameterSpace(foldDim, filesRootDim); setParameterSpace(pSpace); super.execute(aContext); } };
File arffFileTrain = new File(aContext.getStorageLocation(INPUT_KEY_TRAIN, AccessMode.READONLY).getPath() + "/" + TRAINING_DATA_KEY); File arffFileTest = new File(aContext.getStorageLocation(INPUT_KEY_TEST, AccessMode.READONLY).getPath() + "/" + TRAINING_DATA_KEY); new File(aContext.getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE) .getAbsolutePath() + "/" + FEATURE_SELECTION_DATA_KEY), selector.toResultsString()); try { File fsResultsFile = new File(aContext.getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE).getAbsolutePath() + "/" + FEATURE_SELECTION_DATA_KEY); File evalOutput = new File(aContext.getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE) .getPath() + "/" + EVALUATION_DATA_KEY); DataSink.write(aContext.getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE) .getAbsolutePath() + "/" + PREDICTIONS_KEY, testData);
FileOutputStream fos = new FileOutputStream(new File(getContext().getStorageLocation( Constants.TEST_TASK_OUTPUT_KEY, AccessMode.READWRITE) + "/" + Constants.SERIALIZED_ID_OUTCOME_KEY));
throws Exception File storage = getContext().getStorageLocation(TestTask.OUTPUT_KEY, AccessMode.READONLY); Properties props = new Properties(); File arff = new File(storage.getAbsolutePath() + "/" + TestTask.PREDICTIONS_KEY);
File arffFileTrain = new File(aContext.getStorageLocation(INPUT_KEY_TRAIN, AccessMode.READONLY).getPath() + "/" + TRAINING_DATA_KEY); .getParameterKeyPairs(); for (String key : parameterKeys.keySet()) { File file = new File(aContext.getStorageLocation(META_KEY, AccessMode.READONLY), parameterKeys.get(key)); FrequencyDistribution<String> freqDist = new FrequencyDistribution<String>(); FileOutputStream fileOut = new FileOutputStream(aContext.getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE).getPath() + "/" + MODEL_KEY);
throws Exception File storage = getContext().getStorageLocation(TestTask.OUTPUT_KEY, AccessMode.READONLY); FileOutputStream fos = new FileOutputStream(new File(getContext().getStorageLocation( TestTask.OUTPUT_KEY, AccessMode.READWRITE) + "/" + PR_CURVE_KEY));
File arffFile = new File(aContext.getStorageLocation(INPUT_KEY, AccessMode.READONLY) .getPath() + "/" + TRAINING_DATA_KEY); .getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE).getPath() + "/" + StringUtils.replace(EVALUATION_DATA_KEY, "#", String.valueOf(n))); aContext.getStorageLocation(OUTPUT_KEY, AccessMode.READWRITE).getAbsolutePath() + "/" + StringUtils.replace(PREDICTIONS_KEY, "#", String.valueOf(n)), test);
AnalysisEngineDescription xmiWriter = createEngineDescription(BinaryCasWriter.class, BinaryCasWriter.PARAM_TARGET_LOCATION, aContext.getStorageLocation(output, AccessMode.READWRITE).getPath(), BinaryCasWriter.PARAM_FORMAT, "0");