CDMahoutEvaluator { public static void evaluate(List<? extends Rule> rules, int target, Path inpath, Path output, Collection<CDFitness> evaluations, DatasetSplit split) throws IOException, InterruptedException, ClassNotFoundException { Configuration conf = new Configuration(); FileSystem fs = FileSystem.get(inpath.toUri(), conf); Preconditions.checkArgument(fs.exists(inpath) && fs.getFileStatus(inpath).isDir(), "%s is not a directory", inpath); Job job = new Job(conf); configureJob(job, rules, target, inpath, output, split); job.waitForCompletion(true); importEvaluations(fs, conf, output, evaluations); } private  CDMahoutEvaluator(); static void evaluate(List<? extends Rule> rules,
                              int target,
                              Path inpath,
                              Path output,
                              Collection<CDFitness> evaluations,
                              DatasetSplit split); static void initializeDataSet(Path inpath); static CDFitness evaluate(Rule rule, int target, Path inpath, Path output, DatasetSplit split); static void evaluate(List<? extends Rule> rules,
                              int target,
                              Path inpath,
                              Path output,
                              Collection<CDFitness> evaluations);  }
@Test public void testEvaluate() throws Exception { int nbrules = 100; Random rng = RandomUtils.getRandom(); int target = 1; List<Rule> rules = new ArrayList<Rule>(); for (int index = 0; index < nbrules; index++) { rules.add(new RandomRule(index, target, rng)); } FileSystem fs = FileSystem.get(new Configuration()); Path input = fs.makeQualified(new Path(Resources.getResource("wdbc").toString())); CDMahoutEvaluator.initializeDataSet(input); List<CDFitness> results = new ArrayList<CDFitness>(); Path output = getTestTempDirPath("output"); fs = output.getFileSystem(new Configuration()); fs.delete(output, true); CDMahoutEvaluator.evaluate(rules, target, input, output, results); for (int index = 0; index < nbrules; index++) { assertEquals("rule " + index, RandomRuleResults.getResult(index), results.get(index)); } }
@Test public void testEvaluate() throws Exception { int nbrules = 100; Random rng = RandomUtils.getRandom(); int target = 1; List<Rule> rules = Lists.newArrayList(); for (int index = 0; index < nbrules; index++) { rules.add(new RandomRule(index, target, rng)); } FileSystem fs = FileSystem.get(new Configuration()); Path input = fs.makeQualified(new Path(Resources.getResource("wdbc").toURI())); CDMahoutEvaluator.initializeDataSet(input); List<CDFitness> results = Lists.newArrayList(); Path output = getTestTempDirPath("output"); fs = output.getFileSystem(new Configuration()); fs.delete(output, true); CDMahoutEvaluator.evaluate(rules, target, input, output, results); for (int index = 0; index < nbrules; index++) { assertEquals("rule " + index, RandomRuleResults.getResult(index), results.get(index)); } }