Commit d3ac1bc3 authored by Pierre-Emmanuel Viel's avatar Pierre-Emmanuel Viel

When a cluster is empty for KMeans, it's better to give it the point from…

When a cluster is empty for KMeans, it's better to give it the point from another cluster j that is the furthest one from center j.
parent 26f5d2d6
......@@ -759,10 +759,13 @@ private:
for (int k=0; k<indices_length; ++k) {
if (belongs_to[k]==j) {
belongs_to[k] = i;
count[j]--;
count[i]++;
break;
// for cluster j, we move the furthest element from the center to the empty cluster i
if ( distance_(dataset_[indices[k]], dcenters[j], veclen_) == radiuses[j] ) {
belongs_to[k] = i;
count[j]--;
count[i]++;
break;
}
}
}
converged = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment