Question: need help with kmeans algorithm, where it says replace To color each point according to its cluster, we need to specify a label for each

need help with kmeans algorithm, where it says replace

need help with kmeans algorithm, where it says replace To color each

To color each point according to its cluster, we need to specify a label for each point. A label is just an integer >= 0. The label for all points in the same cluster must be the same. So we make a function get_labels(x, centroids). This function takes in our N x 2 data matrix X, and our k x 2 centroid matrix. It should return a Nx1 numpy array labels, such that labels[i] is the index of the cluster of the i 'th point. To do this, we should iterate over all the points. For each point we should iterate over all the centroids, and choose the one which is the closest (least Euclidean distance) to the point. We can simply use the index of that centroid ( 0 = 0. The label for all points in the same cluster must be the same. So we make a function get_labels(x, centroids). This function takes in our N x 2 data matrix X, and our k x 2 centroid matrix. It should return a Nx1 numpy array labels, such that labels[i] is the index of the cluster of the i 'th point. To do this, we should iterate over all the points. For each point we should iterate over all the centroids, and choose the one which is the closest (least Euclidean distance) to the point. We can simply use the index of that centroid ( 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!