KlimentLagrangiewicz / k-means-in-C

Implementation of k-means algorithm in C (standard C89/C90)
0 stars 1 forks source link

The algorithm does not iterate #1

Open Michelcyc opened 5 days ago

Michelcyc commented 5 days ago

I noticed that, the algorithm only do one iteration.

KlimentLagrangiewicz commented 5 days ago

Thank you very much for the note.

This behavior was due to the fact that flag did not change its value by 1 on the first iteration, because the initial splitting and the splitting obtained on the first iteration were the same. These splits relied on the centers selected at the beginning, but the recalculation of the centers happens at the end of check_splitting. I replaced the subroutine to calculate the initial splitting with setting the value of all elements of y array to -1. Now the check_splitting subroutine should cyclic through recalculating a splitting with checking for splitting variability, and recalculating a centers.