Question: K-means Clustering - From Scratch Implementation in Python Note: In this lab you'll are not allowed to use any external library for the K-Means algorithm.

K-means Clustering - From Scratch Implementation in Python

Note: In this lab you'll are not allowed to use any external library for the K-Means algorithm. However you may use libraries such as Numpy or Matplotlib for array handling and visualisation

Lab Tasks:

Create a function named kmeans with the following details:

the function should accept a matrix of data points, number os clusters and the number of iterations

should compute the cluster centers (centroids)

for distance measurement use the Euclidean distance

should keep track of the data points that belong to a certain cluster

return centroids along with the points that belong to them (use Dictionary)

For data point generate random data in two-dimensional space between -5 and 10

see numpy library for that

Plot the data points as cluster using Matplotlib

Note:

submit a code script with the code for k-means and visualisation

you will be marked on code organisation that includes naming conventions and best coding practices

use appropriate data structures, such as lists, dictionaries etc.

use decent comments to elaborate a key steps in the algorithm

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!