K means algorithm implmeneted both in python
and cpp
, in order to show the differences in speed of processing the data of each.
The data set is 100 points with (x,y)
coordinates within each point.
The algorithm is explained well in wikipedia.
The algorithm in python
is run via http://www.codeskulptor.org/ online python
enviroment.
In the Python
algorithm, as it can be seen I have circled the centers of the clusters that were found after approximately 12 iterations of the algorithm. (After 12 iterations the center of the clusters stopped changing significantly).
At the end of the run of the Python
algorithm, an output of the results is generated (The runtime calculation does not include output production):
It is clearly seen that the cpp
language is much faster in computing that data compared to python
.