K-Means

K-Means Algorithm

Step 1

--Arbitrarily choose from the given sample set k initial cluster centres,

M(0)(j) = [m(0)1(j), m(0)2(j), ,, m(0)n(j)]   j = 1, 2, , K,

e.g., the first K samples of the sample set

or can also be generated randomly

Set t = 0 (t is the iteration index)


Step 2

--Assign each of the samples X(i) = [x1(i), x2(i), …, xn(i)], i = 1, 2, ….N, to one of the clusters according to the distance between the sample and the centre of the cluster:
K-Means_第1张图片

Step 3

--Update the cluster centres to get

M(t+1)(j) = [m(t+1)1(j), m(t+1)2(j), ,, m(t+1)n(j)] ; j = 1, 2, K

according to

K-Means_第2张图片

N(t)j is the number of samples in C(t)j


Step 4

--Calculate the error of approximation


Step 5

--If the terminating criterion is met, then stop, otherwise

Set t = t+1

Go to Step 2.

即:

K-Means_第3张图片

你可能感兴趣的:(机器学习,模式识别)