机器学习(八) — K-means

model 5 — K-means

1 definition

  1. randomly initialize K cluster centroids μ 1 , μ 2 , ⋯ \mu_1, \mu_2, \cdots μ1,μ2,
  2. repeat:
    • assign each point to its closest centroid μ \mu μ
    • recompute the centroids(average of the closest point)

机器学习(八) — K-means_第1张图片

2 optimazation objective

  1. c ( i ) c^{(i)} c(i) = index of cluster to which example x ( i ) x^{(i)} x(i) is currently assigned
  2. μ k \mu_k μk = cluster centroid k
  3. μ c ( i ) \mu_{c^{(i)}} μc(i) = cluster centroid of cluster to which example x ( i ) x^{(i)} x(i) has been assigned

J = 1 m ∑ i = 1 m ∥ x ( i ) − μ c ( i ) ∥ J = \frac{1}{m} \sum_{i=1}^m \| x^{(i)} - \mu_{c^{(i)}} \| J=m1i=1mx(i)μc(i)

3 randomly initialization

for i = 1 to n(usually 50 to 1000)
	randomly initialize K-means
	run K-means
	compute cost function
	
pick set of clusters that give the lowest cost

你可能感兴趣的:(机器学习,机器学习,kmeans,人工智能)