flushInput(); m_NewBatch = true;
  public boolean batchFinished() throws Exception {    if (getInputFormat() == null) {      throw new IllegalStateException("No input instance format defined");    }    Instances toFilter = getInputFormat();    Instances toFilterIgnoringAttributes = toFilter;    // filter out attributes if necessary    if (m_IgnoreAttributesRange != null) {      toFilterIgnoringAttributes = new Instances(toFilter);      Filter removeAttributes = new Remove();      ((Remove)removeAttributes).setAttributeIndices(m_IgnoreAttributesRange.getRanges());      ((Remove)removeAttributes).setInvertSelection(false);      removeAttributes.setInputFormat(toFilter);      for (int i = 0; i < toFilter.numInstances(); i++) {	removeAttributes.input(toFilter.instance(i));      }      removeAttributes.batchFinished();      toFilterIgnoringAttributes = removeAttributes.getOutputFormat();      Instance tempInst;      while ((tempInst = removeAttributes.output()) != null) {	toFilterIgnoringAttributes.add(tempInst);      }    }    // build the clusterer    m_Clusterer.buildClusterer(toFilterIgnoringAttributes);    // create output dataset with new attribute    Instances filtered = new Instances(toFilter, 0);     FastVector nominal_values = new FastVector(m_Clusterer.numberOfClusters());    for (int i=0; i<m_Clusterer.numberOfClusters(); i++) {      nominal_values.addElement("cluster" + (i+1));     }    filtered.insertAttributeAt(new Attribute("cluster", nominal_values),			       filtered.numAttributes());    setOutputFormat(filtered);    Instance original, processed;    // build new dataset    for (int i=0; i<toFilter.numInstances(); i++) {            original = toFilter.instance(i);      // copy values      double[] instanceVals = new double[filtered.numAttributes()];      for(int j = 0; j < toFilter.numAttributes(); j++) {	instanceVals[j] = original.value(j);      }      // add cluster to end      instanceVals[toFilter.numAttributes()]	= m_Clusterer.clusterInstance(toFilterIgnoringAttributes.instance(i));            // create new instance      if (original instanceof SparseInstance) {	processed = new SparseInstance(original.weight(), instanceVals);      } else {	processed = new Instance(original.weight(), instanceVals);      }      copyStringValues(original, false, original.dataset(), getOutputStringIndex(),		       getOutputFormat(), getOutputStringIndex());      processed.setDataset(filtered);            push(processed);    }    return (numPendingOutput() != 0);  }