Skip to content

Commit 957490a

Browse files
committed
computation of objective needs to incorporate cluster size
1 parent 2970f3d commit 957490a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/fast-kmeans-anticlustering.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ void fast_kmeans_anticlustering(double *data, int *N, int *M, int *K, int *frequ
121121
tmp_obj_cl2 = euclidean_squared(OVERALL_CENTROID, tmp_center2, m);
122122

123123
// Update objective
124-
tmp_reduction = tmp_obj_cl1 + tmp_obj_cl2 - OBJ_BY_CLUSTER[cl1] - OBJ_BY_CLUSTER[cl2];
124+
tmp_reduction = tmp_obj_cl1 * frequencies[cl1] + tmp_obj_cl2 * frequencies[cl2] -
125+
OBJ_BY_CLUSTER[cl1] * frequencies[cl1] - OBJ_BY_CLUSTER[cl2] * frequencies[cl2];
125126

126127
// Update `best` variables if objective was improved
127128
if (tmp_reduction < best_reduction) {

0 commit comments

Comments
 (0)