Program: 117195
Project: 117195
Buggy source:
/** 
 * Selects features using backward elimination in Additive Groves.
 * @param trainSet the training set.
 * @param validSet the validation set.
 * @param learner the learner to use.
 * @param baggingIters the number of bagging iterations.
 * @param numTrees the number of trees in a grove.
 * @param alpha the alpha.
 * @param numIters the number of iterations to estimate the mean and std for full complexity models.
 * @return the list of selected features and <mean, std> pair for full complexity models.
 */
public static Pair<List<Attribute>,DoublePair> select(Instances trainSet,Instances validSet,AdditiveGrovesLearner learner,int baggingIters,int numTrees,double alpha,int numIters){
  List<Attribute> attributes=trainSet.getAttributes();
  List<Attribute> selected=new ArrayList<>(attributes);
  DoublePair perf=null;
  for (; ; ) {
    if (selected.size() == 0) {
      break;
    }
    boolean changed=false;
    trainSet.setAttributes(selected);
    perf=evaluateModel(trainSet,validSet,learner,baggingIters,numTrees,alpha,numIters);
    System.out.println("String_Node_Str" + perf.v1 + "String_Node_Str"+ perf.v2);
    int i;
    for (i=0; i < selected.size(); ) {
      List<Attribute> attList=new ArrayList<>(selected);
      Attribute attr=attList.get(i);
      System.out.println("String_Node_Str" + attr.getName());
      attList.remove(i);
      trainSet.setAttributes(attList);
      Regressor regressor=learner.runLayeredTraining(trainSet,baggingIters,numTrees,alpha);
      double rmse=Evaluator.evalRMSE(regressor,validSet);
      System.out.println("String_Node_Str" + attr.getName() + "String_Node_Str"+ rmse);
      if (perf.v1 - perf.v2 * 3 <= rmse && rmse <= perf.v1 + perf.v2 * 3) {
        selected.remove(i);
        changed=true;
        System.out.println("String_Node_Str" + attr.getName());
      }
 else {
        i++;
      }
    }
    if (!changed) {
      break;
    }
  }
  trainSet.setAttributes(attributes);
  return new Pair<List<Attribute>,DoublePair>(selected,perf);
}

Fixed version (ground truth):
/** 
 * Selects features using backward elimination in Additive Groves.
 * @param trainSet the training set.
 * @param validSet the validation set.
 * @param learner the learner to use.
 * @param baggingIters the number of bagging iterations.
 * @param numTrees the number of trees in a grove.
 * @param alpha the alpha.
 * @param numIters the number of iterations to estimate the mean and std for full complexity models.
 * @return the list of selected features and $lt;mean, std$gt; pair for full complexity models.
 */
public static Pair<List<Attribute>,DoublePair> select(Instances trainSet,Instances validSet,AdditiveGrovesLearner learner,int baggingIters,int numTrees,double alpha,int numIters){
  List<Attribute> attributes=trainSet.getAttributes();
  List<Attribute> selected=new ArrayList<>(attributes);
  DoublePair perf=null;
  for (; ; ) {
    if (selected.size() == 0) {
      break;
    }
    boolean changed=false;
    trainSet.setAttributes(selected);
    perf=evaluateModel(trainSet,validSet,learner,baggingIters,numTrees,alpha,numIters);
    System.out.println("String_Node_Str" + perf.v1 + "String_Node_Str"+ perf.v2);
    int i;
    for (i=0; i < selected.size(); ) {
      List<Attribute> attList=new ArrayList<>(selected);
      Attribute attr=attList.get(i);
      System.out.println("String_Node_Str" + attr.getName());
      attList.remove(i);
      trainSet.setAttributes(attList);
      Regressor regressor=learner.runLayeredTraining(trainSet,baggingIters,numTrees,alpha);
      double rmse=Evaluator.evalRMSE(regressor,validSet);
      System.out.println("String_Node_Str" + attr.getName() + "String_Node_Str"+ rmse);
      if (perf.v1 - perf.v2 * 3 <= rmse && rmse <= perf.v1 + perf.v2 * 3) {
        selected.remove(i);
        changed=true;
        System.out.println("String_Node_Str" + attr.getName());
      }
 else {
        i++;
      }
    }
    if (!changed) {
      break;
    }
  }
  trainSet.setAttributes(attributes);
  return new Pair<List<Attribute>,DoublePair>(selected,perf);
}