Course week 1 lab 1 find_closest_centroids


It threw me a bit that I had to use the numpy norm function and for a while I was unsuccessfully trying to implement the function myself. So really this is a two part questions

  1. Did I miss the fact in the course material
  2. The norm function seems pretty straight forward, but I kept getting it wrong. Is there an example of the implementation somewhere?
1 Like

Hi @lionbee ,
Are you using correct definition for norm ||x^{(i)} - \mu_j||^2?
As there are two columns per row for X[i] and mu_j, are you taking account both of columns when you are calculating norm for particular row?

1 Like

In addition to ritik5

In the course 3 week 1 in ML Specialization there are a k-means algorithm task it will helping you so much and another resource It is Create a K-Means Clustering Algorithm from Scratch in Python | by Turner Luke | Towards Data Science a clear example with code I hope also help you

please feel free to ask any questions,


Mystery solved. I forgot to take the sqaureroot :face_holding_back_tears:

This is a really good resource, thank you