log.error("No Decision Forest found!");
return;
}
// load the dataset
Dataset dataset = Dataset.load(getConf(), datasetPath);
DataConverter converter = new DataConverter(dataset);
log.info("Sequential classification...");
long time = System.currentTimeMillis();
Random rng = RandomUtils.getRandom();
List<double[]> resList = Lists.newArrayList();
if (dataFS.getFileStatus(dataPath).isDir()) {
//the input is a directory of files
testDirectory(outputPath, converter, forest, dataset, resList, rng);
} else {
// the input is one single file
testFile(dataPath, outputPath, converter, forest, dataset, resList, rng);
}
time = System.currentTimeMillis() - time;
log.info("Classification Time: {}", DFUtils.elapsedTime(time));
if (analyze) {
if (dataset.isNumerical(dataset.getLabelId())) {
RegressionResultAnalyzer regressionAnalyzer = new RegressionResultAnalyzer();
double[][] results = new double[resList.size()][2];
regressionAnalyzer.setInstances(resList.toArray(results));
log.info("{}", regressionAnalyzer);
} else {
ResultAnalyzer analyzer = new ResultAnalyzer(Arrays.asList(dataset.labels()), "unknown");
for (double[] r : resList) {
analyzer.addInstance(dataset.getLabelString(r[0]),
new ClassifierResult(dataset.getLabelString(r[1]), 1.0));
}
log.info("{}", analyzer);
}
}
}