Instances toFilter = getInputFormat(); Instances toFilterIgnoringAttributes = toFilter;
if (outputFormatPeek() == null) {
  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 || toFilter.classIndex() >= 0) {      toFilterIgnoringAttributes = new Instances(toFilter);      Filter removeAttributes = new Remove();      String rangeString = "";      if (m_ignoreAttributesRange != null) {	rangeString += m_ignoreAttributesRange.getRanges();      }      if (toFilter.classIndex() >= 0) {	if (rangeString.length() > 0) {	  rangeString += (","+(toFilter.classIndex()+1));	  	} else {	  rangeString = ""+(toFilter.classIndex()+1);	}      }      ((Remove)removeAttributes).setAttributeIndices(rangeString);      ((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    int numAtts = (toFilter.classIndex() >=0)      ? m_clusterer.numberOfClusters() + 1      : m_clusterer.numberOfClusters();    FastVector attInfo = new FastVector(numAtts);    for (int i = 0; i < m_clusterer.numberOfClusters(); i++) {      attInfo.addElement(new Attribute("pCluster"+i));    }    if (toFilter.classIndex() >= 0) {      attInfo.addElement(toFilter.classAttribute().copy());    }    Instances filtered = new Instances(toFilter.relationName()+"_clusterMembership",				      attInfo, 0);    setOutputFormat(filtered);    Instance original, processed;    double [] probs;    // build new daaset    for (int i = 0; i < toFilter.numInstances(); i++) {      original = toFilter.instance(i);            probs = m_clusterer.	distributionForInstance(toFilterIgnoringAttributes.instance(i));            // set up values      double [] instanceVals = new double[filtered.numAttributes()];      for (int j = 0; j < probs.length; j++) {	instanceVals[j] = probs[j];      }      if (toFilter.classIndex() >= 0) {	instanceVals[instanceVals.length - 1] = original.classValue();      }            processed = new Instance(original.weight(), instanceVals);      processed.setDataset(filtered);      push(processed);    }    return (numPendingOutput() != 0);  }