m_ClusterStdDevs = new Instances(m_instances, m_NumClusters);
  public void buildClusterer(Instances data) throws Exception {    m_Iterations = 0;    if (data.checkForStringAttributes()) {      throw  new Exception("Can't handle string attributes!");    }    m_ReplaceMissingFilter = new ReplaceMissingValues();    m_ReplaceMissingFilter.setInputFormat(data);    m_instances = Filter.useFilter(data, m_ReplaceMissingFilter);    m_Min = new double [m_instances.numAttributes()];    m_Max = new double [m_instances.numAttributes()];    for (int i = 0; i < m_instances.numAttributes(); i++) {      m_Min[i] = m_Max[i] = Double.NaN;    }    for (int i = 0; i < m_instances.numInstances(); i++) {      updateMinMax(m_instances.instance(i));    }        m_ClusterCentroids = new Instances(m_instances, m_NumClusters);    m_ClusterStdDevs = new Instances(m_instances, m_NumClusters);    m_ClusterAssignments = new int [m_instances.numInstances()];    Random RandomO = new Random(m_Seed);    boolean [] selected = new boolean[m_instances.numInstances()];    int instIndex;    for (int i = 0; i < m_NumClusters; i++) {      do {	instIndex = Math.abs(RandomO.nextInt()) % 	  m_instances.numInstances();      } while (selected[instIndex]);      m_ClusterCentroids.add(m_instances.instance(instIndex));      selected[instIndex] = true;    }    selected = null;    boolean converged = false;    while (!converged) {      m_Iterations++;      converged = true;      for (int i = 0; i < m_instances.numInstances(); i++) {	Instance toCluster = m_instances.instance(i);	int newC = clusterProcessedInstance(toCluster);	if (newC != m_ClusterAssignments[i]) {	  converged = false;	}	m_ClusterAssignments[i] = newC;	//	System.out.println(newC);      }            Instances [] tempI = new Instances[m_NumClusters];      // update centroids      m_ClusterCentroids = new Instances(m_instances, m_NumClusters);      for (int i = 0; i < m_NumClusters; i++) {	tempI[i] = new Instances(m_instances, 0);      }      for (int i = 0; i < m_instances.numInstances(); i++) {	tempI[m_ClusterAssignments[i]].add(m_instances.instance(i));      }      for (int i = 0; i < m_NumClusters; i++) {	double [] vals = new double[m_instances.numAttributes()];	double [] vals2 = new double[m_instances.numAttributes()];	for (int j = 0; j < m_instances.numAttributes(); j++) {	  vals[j] = tempI[i].meanOrMode(j);	  if (m_instances.attribute(j).isNumeric()) {	    Stats ns = tempI[i].attributeStats(j).numericStats;	    vals2[j] = ns.stdDev;	  } else {	    vals2[j] = Instance.missingValue();	  }	}	m_ClusterCentroids.add(new Instance(1.0, vals));	m_ClusterStdDevs.add(new Instance(1.0, vals2));      }    }  }