Program: 61219
Project: 61219
Buggy source:
/** 
 * runs one iteration of the procedure.
 * @param rng random numbers generator
 * @param data training data
 * @param m number of random variables to select at each tree-node
 * @param nbtrees number of trees to grow
 * @throws Exception if an error occured while growing the trees
 */
private void runIteration(Random rng,Data data,int m,int nbtrees){
  int nblabels=data.getDataset().nblabels();
  log.info("String_Node_Str");
  Data train=data.clone();
  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);
  ForestPredictions errorM=new ForestPredictions(train.size(),nblabels);
  treeBuilder.setM(m);
  long time=System.currentTimeMillis();
  log.info("String_Node_Str",m);
  DecisionForest forestM=forestBuilder.build(nbtrees,errorM);
  sumTimeM+=System.currentTimeMillis() - time;
  numNodesM+=forestM.nbNodes();
  double oobM=ErrorEstimate.errorRate(trainLabels,errorM.computePredictions(rng));
  ForestPredictions errorOne=new ForestPredictions(train.size(),nblabels);
  treeBuilder.setM(1);
  time=System.currentTimeMillis();
  log.info("String_Node_Str");
  DecisionForest forestOne=forestBuilder.build(nbtrees,errorOne);
  sumTimeOne+=System.currentTimeMillis() - time;
  numNodesOne+=forestOne.nbNodes();
  double oobOne=ErrorEstimate.errorRate(trainLabels,errorOne.computePredictions(rng));
  ForestPredictions testError=new ForestPredictions(test.size(),nblabels);
  MeanTreeCollector treeError=new MeanTreeCollector(test,nbtrees);
  errorOne=new ForestPredictions(test.size(),nblabels);
  if (oobM < oobOne) {
    forestM.classify(test,new MultiCallback(testError,treeError));
    forestOne.classify(test,errorOne);
  }
 else {
    forestOne.classify(test,new MultiCallback(testError,treeError,errorOne));
  }
  sumTestErr+=ErrorEstimate.errorRate(testLabels,testError.computePredictions(rng));
  sumOneErr+=ErrorEstimate.errorRate(testLabels,errorOne.computePredictions(rng));
  sumTreeErr+=treeError.meanTreeError();
}

Fixed version (ground truth):
/** 
 * runs one iteration of the procedure.
 * @param rng random numbers generator
 * @param data training data
 * @param m number of random variables to select at each tree-node
 * @param nbtrees number of trees to grow
 * @throws Exception if an error occured while growing the trees
 */
private void runIteration(Random rng,Data data,int m,int nbtrees){
  int nblabels=data.getDataset().nblabels();
  log.info("String_Node_Str");
  Data train=data.clone();
  Data test=train.rsplit(rng,(int)(data.size() * 0.1));
  int[] labels=data.extractLabels();
  int[] testLabels=test.extractLabels();
  DefaultTreeBuilder treeBuilder=new DefaultTreeBuilder();
  SequentialBuilder forestBuilder=new SequentialBuilder(rng,treeBuilder,train);
  ForestPredictions errorM=new ForestPredictions(data.size(),nblabels);
  treeBuilder.setM(m);
  long time=System.currentTimeMillis();
  log.info("String_Node_Str",m);
  DecisionForest forestM=forestBuilder.build(nbtrees,errorM);
  sumTimeM+=System.currentTimeMillis() - time;
  numNodesM+=forestM.nbNodes();
  double oobM=ErrorEstimate.errorRate(labels,errorM.computePredictions(rng));
  ForestPredictions errorOne=new ForestPredictions(data.size(),nblabels);
  treeBuilder.setM(1);
  time=System.currentTimeMillis();
  log.info("String_Node_Str");
  DecisionForest forestOne=forestBuilder.build(nbtrees,errorOne);
  sumTimeOne+=System.currentTimeMillis() - time;
  numNodesOne+=forestOne.nbNodes();
  double oobOne=ErrorEstimate.errorRate(labels,errorOne.computePredictions(rng));
  ForestPredictions testError=new ForestPredictions(test.size(),nblabels);
  MeanTreeCollector treeError=new MeanTreeCollector(test,nbtrees);
  errorOne=new ForestPredictions(test.size(),nblabels);
  if (oobM < oobOne) {
    forestM.classify(test,new MultiCallback(testError,treeError));
    forestOne.classify(test,errorOne);
  }
 else {
    forestOne.classify(test,new MultiCallback(testError,treeError,errorOne));
  }
  sumTestErr+=ErrorEstimate.errorRate(testLabels,testError.computePredictions(rng));
  sumOneErr+=ErrorEstimate.errorRate(testLabels,errorOne.computePredictions(rng));
  sumTreeErr+=treeError.meanTreeError();
}