/* Clear records for incremental k-means */
for (int i = 0; i < this.centroids.length; ++i) {
this.newClusters[i] = new ArrayList<Instance>();
this.newCentroids[i] = new HashSparseVector();
this.newQualities[i] = 0.0f;
}
for (int clusterNum = 0; clusterNum < this.centroids.length; ++clusterNum) { // iterate over clusters
for (int docNum = 0; docNum < this.assignedClusters[clusterNum].size(); ++docNum) { // iterate over docs
/*
* Store the document the loops have selected in the 'doc' variable.
* Store is vector in the 'docVec' variable for easy access.
*/
Instance doc = this.assignedClusters[clusterNum].get(docNum);
HashSparseVector docVec = (HashSparseVector) doc.getData();
int bestClusterNum = clusterNum; // Assume we are already in the best cluster.
double distanceToCurrentCentroid =
this.centroids[clusterNum].distanceEuclidean(docVec);
double squareDistanceOfBestCluster = distanceToCurrentCentroid;