Create a K-means Clustering algorithm using gravity as distance

Job ID: 31930189

Budget: $30 – $250 USD

Instructions:
This is a K-means Clustering Algorithm. The code for the K-means Clustering algorithm is attached in the zip file. I need to use the Gravity as distance to build the K-means Clustering Algorithm. Usually K-means Clustering Algorithm works as follow:
1) We initialize the random centroids.
2) Calculate the distance using Euclidean distance between centroid and data point
3) The data point having min distance to the centroid, it is merged to the cluster.
4) When the distance between the old and new centroids do not change we say the cluster is formed.
The above process takes places iteratively until the centroid is not changed, and we plot the final cluster.
In the K-means Clustering algorithm with gravity distance, we have a catch. It follow the following Algorithm.
1) In the first iteration, the algorithm initialize the centroids randomly in regular K-means, after that we measure minimum distance and make the first cluster.
2) In the second Iteration, we got the cluster, now we measure the clusters mass i.e the number of data point in the a cluster.
3) Once we have measure the number of Instance, we measure distance, that is the centroid with strongest force with following equation:

Gravity_distance(massOfCLusters, Centroids, x):
Force = massOfCluster**2/ euclideanDistance(centroid, datapoint)**2
Return force
4) If there is strongest force between a data point and centroid of the cluster the data point is merged.
5) So, from second Iteration, the process takes place iteratively, till the centroid do not change.
6) We plot the labeles of K-means Clustering, On the sctter plot.

Now, I have attached the program with the explanation of the program, you need to modify the same program and use the same dataset that is generated by the program.
I am also attachning the file so to have a intuition about gravity equation and how it should work in K-means Clustering Algorithm.

Kindly modify in the program itself that I am attaching.
Related categories: Python Data Mining Data Science