m_makeIndicatorFilter.setValueIndex(i); newInsts=Filter.useFilter(metaData,m_makeIndicatorFilter);
  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)));      }    }    // Rebuild all the base classifiers on the full training data    for (int i = 0; i < numClassifiers; i++) {      getBaseClassifier(i).buildClassifier(newData);    }       // Build meta classifiers    m_MetaClassifiers = Classifier.makeCopies(m_MetaClassifier,newData.numClasses());    m_makeIndicatorFilter = new weka.filters.unsupervised.attribute.MakeIndicator();    m_makeIndicatorFilter.setInputFormat(metaData);    m_makeIndicatorFilter.setAttributeIndex("" + (metaData.classIndex() + 1));    m_makeIndicatorFilter.setNumeric(true);    m_attrFilter = new weka.filters.unsupervised.attribute.Remove();    m_attrFilter.setInputFormat(m_makeIndicatorFilter.getOutputFormat());    m_attrFilter.setInvertSelection(true);    int [] arrIdc = new int[m_BaseClassifiers.length+1];    arrIdc[m_BaseClassifiers.length]=metaData.numAttributes()-1;    Instances newInsts;    for (int i = 0; i<m_MetaClassifiers.length; i++) {      for (int j = 0; j<m_BaseClassifiers.length; j++)          arrIdc[j]=newData.numClasses()*j+i;      m_attrFilter.setAttributeIndicesArray(arrIdc);      m_makeIndicatorFilter.setValueIndex(i);      newInsts=Filter.useFilter(metaData,m_makeIndicatorFilter);      m_attrFilter.setInputFormat(m_makeIndicatorFilter.getOutputFormat());      newInsts=Filter.useFilter(newInsts,m_attrFilter);      newInsts.setClassIndex(newInsts.numAttributes()-1);      m_MetaClassifiers[i].buildClassifier(newInsts);    }  }