Data test = train.rsplit(rng, (int) (data.size() * 0.1));
int[] trainLabels = train.extractLabels();
int[] testLabels = test.extractLabels();
DefaultTreeBuilder treeBuilder = new DefaultTreeBuilder();
SequentialBuilder forestBuilder = new SequentialBuilder(rng, treeBuilder, train);
// grow a forest with m = log2(M)+1
ForestPredictions errorM = new ForestPredictions(train.size(), nblabels); // oob error when using m =
// log2(M)+1
treeBuilder.setM(m);
long time = System.currentTimeMillis();
log.info("Growing a forest with m={}", m);
DecisionForest forestM = forestBuilder.build(nbtrees, errorM);
sumTimeM += System.currentTimeMillis() - time;
numNodesM += forestM.nbNodes();
double oobM = ErrorEstimate.errorRate(trainLabels, errorM.computePredictions(rng)); // oob error estimate
// when m = log2(M)+1
// grow a forest with m=1
ForestPredictions errorOne = new ForestPredictions(train.size(), nblabels); // oob error when using m = 1
treeBuilder.setM(1);
time = System.currentTimeMillis();
log.info("Growing a forest with m=1");
DecisionForest forestOne = forestBuilder.build(nbtrees, errorOne);
sumTimeOne += System.currentTimeMillis() - time;