@Test
public void testRegression() throws DescriptorException {

  Data[] datas = generateTrainingDataB();
  DecisionForest[] forests = new DecisionForest[datas.length];
  for (int i = 0; i < datas.length; i++) {
    Data[] subDatas = new Data[datas.length - 1];
    int k = 0;
    for (int j = 0; j < datas.length; j++) {
      if (j != i) {
        subDatas[k] = datas[j];
        k++;
      }
    }
    forests[i] = buildForest(subDatas);
  }
  
  double[][] predictions = new double[datas[0].size()][];
  forests[0].classify(datas[0], predictions);
  assertArrayEquals(new double[]{20.0, 20.0}, predictions[0], EPSILON);
  assertArrayEquals(new double[]{39.0, 29.0}, predictions[1], EPSILON);
  assertArrayEquals(new double[]{Double.NaN, 29.0}, predictions[2], EPSILON);
  assertArrayEquals(new double[]{Double.NaN, 23.0}, predictions[17], EPSILON);
  predictions = new double[datas[1].size()][];
  forests[1].classify(datas[1], predictions);
  assertArrayEquals(new double[]{30.0, 29.0}, predictions[19], EPSILON);
  predictions = new double[datas[2].size()][];
  forests[2].classify(datas[2], predictions);
  assertArrayEquals(new double[]{29.0, 28.0}, predictions[9], EPSILON);
  assertEquals(20.0, forests[0].classify(datas[0].getDataset(), rng, datas[0].get(0)), EPSILON);
  assertEquals(34.0, forests[0].classify(datas[0].getDataset(), rng, datas[0].get(1)), EPSILON);
  assertEquals(29.0, forests[0].classify(datas[0].getDataset(), rng, datas[0].get(2)), EPSILON);
}