C3_W1_KMeans_Assignment lab

How did the point initialized in green region end up in blue? isnt this type of case should be rejected by comparing the cost function J of the different random initializations.

1 Like

Hello @tarunsaxena1000,

I don’t think our K-mean function has implemented anything to reject a certain initialization.

The colors of the data points should be based on their final classes. Therefore, your screenshot should be showing that there was a centroid locating at the green area at first, then shifted to the blue area finally.

image

Cheers,
Raymond

3 Likes

hi @rmwkwok thanks for the response, so you are saying that its not possible for 2 centroids to converge at a same point.

1 Like

It’s possible, because it’s not prohitbited by the algorithm. Rejecting some initial randomized conditions won’t 100% eliminate that possibility either. However, if you run 100 K-means on the dataset, it is much less likely to happen to all of the trials. Try it out yourself and see if you can come up with a way to use “running more K-means” to get rid of that unwanted situation.

2 Likes

When you set the initial centroids, it is best to use a “unique” sorting, so that none of the initial centroids are duplicates.

2 Likes

@TMosh @rmwkwok Thanks for your advices, it really helped me a lot.

2 Likes

You are welcome, @tarunsaxena1000!

2 Likes