Skip to content

Commit 25c616c

Browse files
andiwgkno10
authored andcommitted
add per iteration time to BetulaLloydKMeans
1 parent 6dc5fe9 commit 25c616c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

elki-clustering/src/main/java/elki/clustering/kmeans/BetulaLloydKMeans.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ else if(storeIds) {
200200
private double[][] kmeans(ArrayList<? extends ClusterFeature> cfs, int[] assignment, int[] weights, CFTree<?> tree) {
201201
double[][] means = initialization.chooseInitialMeans(tree, cfs, k);
202202
for(int i = 1; i <= maxiter || maxiter < 0; i++) {
203+
Duration duration = LOG.newDuration(getClass().getName() + "." + i + ".time").begin();
203204
long prevdiststat = diststat;
204205
means = i == 1 ? means : means(assignment, means, cfs, weights);
205206
if(i > 1 && LOG.isStatistics()) {
@@ -209,6 +210,7 @@ private double[][] kmeans(ArrayList<? extends ClusterFeature> cfs, int[] assignm
209210
}
210211
int changed = assignToNearestCluster(assignment, means, cfs, weights);
211212
if(LOG.isStatistics()) {
213+
LOG.statistics(duration.end());
212214
LOG.statistics(new LongStatistic(getClass().getName() + "." + i + ".reassigned", changed));
213215
if(diststat > prevdiststat) {
214216
LOG.statistics(new LongStatistic(getClass().getName() + "." + i + ".distance-computations", diststat - prevdiststat));

0 commit comments

Comments
 (0)