private CentroidClusterModel assinePoints(CentroidClusterModel model){
  double[] values=new double[attributes.size()];
  int i=0;
  for (  Example example : exampleSet) {
    double[] exampleValues=getAsDoubleArray(example,attributes,values);
    double nearestDistance=measure.calculateDistance(model.getCentroidCoordinates(0),exampleValues);
    int nearestIndex=0;
    int id=0;
    for (    Centroid cr : model.getCentroids()) {
      double distance=measure.calculateDistance(cr.getCentroid(),exampleValues);
      if (distance < nearestDistance) {
        nearestDistance=distance;
        nearestIndex=id;
      }
      id++;
    }
    centroidAssignments[i]=nearestIndex;
    i++;
  }
  model.setClusterAssignments(centroidAssignments,exampleSet);
  return model;
}

private CentroidClusterModel assinePoints ( CentroidClusterModel model ) { double [ ] values = new double [ attributes . size ( ) ] ; int i = 0 ; for ( Example example : exampleSet ) { double [ ] exampleValues = getAsDoubleArray ( example , attributes , values ) ; double nearestDistance = measure . calculateDistance ( model . getCentroidCoordinates ( 0 ) , exampleValues ) ; int nearestIndex = 0 ; int id = 0 ; for ( Centroid cr : model . getCentroids ( ) ) { double distance = measure . calculateDistance ( cr . getCentroid ( ) , exampleValues ) ; if ( distance < nearestDistance ) { nearestDistance = distance ; nearestIndex = id ; } id ++ ; } centroidAssignments [ i ] = nearestIndex ; i ++ ; } model . setClusterAssignments ( centroidAssignments , exampleSet ) ; return model ; }
assign the points to cluster
