if (!(m_MetaClassifier instanceof DistributionClassifier)) { Classifier temp = m_MetaClassifier; m_MetaClassifier = new DistributionMetaClassifier(); ((DistributionMetaClassifier)m_MetaClassifier).setClassifier(temp); }
  public void buildClassifier(Instances data) throws Exception {    if (m_BaseClassifiers.length == 0) {      throw new Exception("No base classifiers have been set");    }    if (m_MetaClassifier == null) {      throw new Exception("No meta classifier has been set");    }    if (!(data.classAttribute().isNominal() ||	  data.classAttribute().isNumeric())) {      throw new Exception("Class attribute has to be nominal or numeric!");    }    Instances newData = new Instances(data);    m_BaseFormat = new Instances(data, 0);    newData.deleteWithMissingClass();    if (newData.numInstances() == 0) {      throw new Exception("No training instances without missing class!");    }    newData.randomize(new Random(m_Seed));    if (newData.classAttribute().isNominal())      newData.stratify(m_NumFolds);    int numClassifiers = m_BaseClassifiers.length;    // Create meta data    Instances metaData = metaFormat(newData);    m_MetaFormat = new Instances(metaData, 0);    for (int j = 0; j < m_NumFolds; j++) {      Instances train = newData.trainCV(m_NumFolds, j);      // Build base classifiers      for (int i = 0; i < m_BaseClassifiers.length; i++) {	getBaseClassifier(i).buildClassifier(train);      }      // Classify test instances and add to meta data      Instances test = newData.testCV(m_NumFolds, j);      for (int i = 0; i < test.numInstances(); i++) {	metaData.add(metaInstance(test.instance(i)));      }    }    // Rebuilt all the base classifiers on the full training data    for (int i = 0; i < numClassifiers; i++) {      getBaseClassifier(i).buildClassifier(newData);    }       // Build meta classifier    m_MetaClassifier.buildClassifier(metaData);  }