m_ClassFilters[i].setAttributeIndex(insts.classIndex() + 1); m_ClassFilters[i].setValueIndex(i + 1);
m_ClassFilters[i].setAttributeIndex(insts.classIndex()); m_ClassFilters[i].setValueIndex(i);
  public void buildClassifier(Instances insts) throws Exception {    Instances newInsts;    if (m_BaseClassifier == null) {      throw new Exception("No base classifier has been set!");    }    if (!insts.classAttribute().isNominal()) {      throw new 	Exception("MultiClassClassifier needs a nominal class!");    }    if (Class.forName(m_BaseClassifier).newInstance() instanceof 	WeightedInstancesHandler) {      // Base classifier can handle weights      insts = new Instances(insts);    } else {      // Use resampling if base classifer can't handle weights and weights not all one      double[] weights = new double[insts.numInstances()];      boolean foundOne = false;      for (int i = 0; i < weights.length; i++) {	weights[i] = insts.instance(i).weight();	if (!Utils.eq(weights[i], weights[0])) {	  foundOne = true;	}      }      if (foundOne) {	insts = insts.resampleWithWeights(new Random(42), weights);      }    }         insts.deleteWithMissingClass();    if (insts.numInstances() == 0) {      throw new Exception("No train instances without missing class!");    }    m_ZeroR = new ZeroR();    m_ZeroR.buildClassifier(insts);    m_Classifiers = new DistributionClassifier[insts.numClasses()];    m_ClassFilters = new MakeIndicatorFilter[insts.numClasses()];    for (int i = 0; i < insts.numClasses(); i++) {      m_Classifiers[i] = (DistributionClassifier)Class.	forName(m_BaseClassifier).newInstance();      if (m_Classifiers[i] instanceof OptionHandler) {	String[] copy = new String[m_Options.length];	System.arraycopy(m_Options, 0, copy, 0, m_Options.length);	((OptionHandler)m_Classifiers[i]).setOptions(copy);      }      m_ClassFilters[i] = new MakeIndicatorFilter();      m_ClassFilters[i].setAttributeIndex(insts.classIndex() + 1);      m_ClassFilters[i].setValueIndex(i + 1);      m_ClassFilters[i].setNumeric(false);      m_ClassFilters[i].inputFormat(insts);      newInsts = Filter.useFilter(insts, m_ClassFilters[i]);      m_Classifiers[i].buildClassifier(newInsts);    }  }