Simple k-means clustering (centroid-based) using Python
Python 3.5
Numpy 1.11.0
k-Means clustering is one of the most popular clustering methods in data mining and also in unsupervised machine learning. Here is a simple technique (actually a demonstration of the algorithm) for clustering data using k-Means Clustering method (with centroid-based). This code (for now) uses iterative method but doesn't use stopping or convergence criteria.
Initialize the centroids (number and position of the centroids) in function create_centroids()
.
Note that, the algorithm may find suboptimal solution if the centroids are chosen badly.
The output of this code are the data points with the cluster number/label and also the final centroids position.