m_Classifier = bestClassifier;
  public void buildClassifier(Instances data) throws Exception {    if (m_Classifiers.length == 0) {      throw new Exception("No base classifiers have been set!");    }    Instances newData = new Instances(data);    newData.deleteWithMissingClass();    newData.randomize(new Random(m_Seed));    if (newData.classAttribute().isNominal() && (m_NumXValFolds > 1))      newData.stratify(m_NumXValFolds);    Instances train = newData;               // train on all data by default    Instances test = newData;               // test on training data by default    Classifier bestClassifier = null;    int bestIndex = -1;    double bestPerformance = Double.NaN;    int numClassifiers = m_Classifiers.length;    for (int i = 0; i < numClassifiers; i++) {      Classifier currentClassifier = getClassifier(i);      Evaluation evaluation;      if (m_NumXValFolds > 1) {	evaluation = new Evaluation(newData);	for (int j = 0; j < m_NumXValFolds; j++) {	  train = newData.trainCV(m_NumXValFolds, j);	  test = newData.testCV(m_NumXValFolds, j);	  currentClassifier.buildClassifier(train);	  evaluation.setPriors(train);	  evaluation.evaluateModel(currentClassifier, test);	}      } else {	currentClassifier.buildClassifier(train);	evaluation = new Evaluation(train);	evaluation.evaluateModel(currentClassifier, test);      }      double error = evaluation.errorRate();      if (m_Debug) {	System.err.println("Error rate: " + Utils.doubleToString(error, 6, 4)			   + " for classifier "			   + currentClassifier.getClass().getName());      }      if ((i == 0) || (error < bestPerformance)) {	bestClassifier = currentClassifier;	bestPerformance = error;	bestIndex = i;      }    }    m_ClassifierIndex = bestIndex;    m_Classifier = bestClassifier;    if (m_NumXValFolds > 1) {      m_Classifier.buildClassifier(newData);    }  }