Implementation of most famous clustering algorithm(K-means) using Expectation(E)-Maximization(M) technique in Python using NumPy.
The given packet contains kmeans_algo module. KMeans class contains implementation of K-means algorithm in OOP way.
methods-
dist(v1,v2)- It calculates and return Euclidean distance between two vectors(v1 and v2).
train(X,k,epochs)-
parameters:
X: a (m,n) shaped NumPy array consisting of m training examples with n attributes.
k: numbers of cluster centres
epochs: Number of times E-step and M-step need to be repeated.
return:
cluster:A Python dictiionary with keys from 0 to k-1.
cluster[i] is a python dictiionary where i denotes ith cluster consisting of two parameters -
'centre': denoting the mean of that all points belonging to that cluster
'points': denoting a list of all the points that falls in that cluster
Submitted by Prateek Kumar (18225prateek)
Download packets of source code on Coders Packet
Comments