m_OutOfBagError = errorSum / outOfBagCount;
else { m_OutOfBagError = 0; }
  public void buildClassifier(Instances data) throws Exception {    // can classifier handle the data?    getCapabilities().testWithFail(data);    // remove instances with missing class    data = new Instances(data);    data.deleteWithMissingClass();        super.buildClassifier(data);    if (m_CalcOutOfBag && (m_BagSizePercent != 100)) {      throw new IllegalArgumentException("Bag size needs to be 100% if " +					 "out-of-bag error is to be calculated!");    }    double outOfBagCount = 0.0;    double errorSum = 0.0;    int bagSize = data.numInstances() * m_BagSizePercent / 100;    Random random = new Random(m_Seed);    for (int j = 0; j < m_Classifiers.length; j++) {      Instances bagData = null;      boolean[] inBag = null;      // create the in-bag dataset      if (m_CalcOutOfBag) {	inBag = new boolean[data.numInstances()];	bagData = resampleWithWeights(data, random, inBag);      } else {	bagData = data.resampleWithWeights(random);	if (bagSize < data.numInstances()) {	  bagData.randomize(random);	  Instances newBagData = new Instances(bagData, 0, bagSize);	  bagData = newBagData;	}      }      if (m_Classifier instanceof Randomizable) {	((Randomizable) m_Classifiers[j]).setSeed(random.nextInt());      }      // build the classifier      m_Classifiers[j].buildClassifier(bagData);      if (m_CalcOutOfBag) {	// calculate out of bag error	for (int i=0; i<inBag.length; i++) {  	  if (!inBag[i]) {	    Instance outOfBagInst = data.instance(i);	    outOfBagCount += outOfBagInst.weight();	    if (data.classAttribute().isNumeric()) {	      errorSum += outOfBagInst.weight() *		Math.abs(m_Classifiers[j].classifyInstance(outOfBagInst)			 - outOfBagInst.classValue());	    } else {	      if (m_Classifiers[j].classifyInstance(outOfBagInst)		  != outOfBagInst.classValue()) {		errorSum += outOfBagInst.weight();	      }	    }	  }	}      }    }    m_OutOfBagError = errorSum / outOfBagCount;  }