OptIgSplit extends IgSplit { @Override public Split computeSplit(Data data, int attr) { if (data.getDataset().isNumerical(attr)) { return numericalSplit(data, attr); } else { return categoricalSplit(data, attr); } }  @Override Split computeSplit(Data data, int attr);  }
@Test public void testComputeSplit() throws Exception { IgSplit ref = new DefaultIgSplit(); IgSplit opt = new OptIgSplit(); Random rng = RandomUtils.getRandom(); Data data = Utils.randomData(rng, NUM_ATTRIBUTES, NUM_INSTANCES); for (int nloop = 0; nloop < 100; nloop++) { int attr = rng.nextInt(data.getDataset().nbAttributes()); Split expected = ref.computeSplit(data, attr); Split actual = opt.computeSplit(data, attr); assertEquals(expected.getIg(), actual.getIg(), EPSILON); assertEquals(expected.getSplit(), actual.getSplit(), EPSILON); } }
@Test public void testComputeSplit() throws Exception { IgSplit ref = new DefaultIgSplit(); IgSplit opt = new OptIgSplit(); Random rng = RandomUtils.getRandom(); Data data = Utils.randomData(rng, NUM_ATTRIBUTES, false, NUM_INSTANCES); for (int nloop = 0; nloop < 100; nloop++) { int attr = rng.nextInt(data.getDataset().nbAttributes()); Split expected = ref.computeSplit(data, attr); Split actual = opt.computeSplit(data, attr); assertEquals(expected.getIg(), actual.getIg(), EPSILON); assertEquals(expected.getSplit(), actual.getSplit(), EPSILON); } }