日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

K-Means 聚类实例sample

發(fā)布時間:2025/3/21 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 K-Means 聚类实例sample 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

假定我們有如下9個點

A1(2, 10) ?A2(2, 5)?A3(8, 4) ?A4(5, 8) ?A5(7, 5)?A6(6, 4)? A7(1, 2)? A8(4, 9)

希望分成3個聚類

初始化選擇?A1(2, 10),? A4(5, 8) ,A7(1, 2)為聚類中心點,兩點距離定義為ρ(a, b) = |x2 – x1| + |y2 – y1|?. ?

第一步

Iteration 1

?

?

???????? (2, 10)

??????? (5, 8)

???????? (1, 2)

?

?

Point

Dist Mean cluster 1

Dist Mean?cluster2

Dist Mean?cluster?3

Cluster

A1

(2, 10)

?

?

?

?

A2

(2, 5)

?

?

?

?

A3

(8, 4)

?

?

?

?

A4

(5, 8)

?

?

?

?

A5

(7, 5)

?

?

?

?

A6

(6, 4)

?

?

?

?

A7

(1, 2)

?

?

?

?

A8

(4, 9)

?

?

?

?


對A1點,計算其到每個cluster?的距離

A1->class1 = |2-2|+|10-10}=0

A1->class2 = |2-5|+|10-8|=5

A1->class3 = |2-1|+|10-2|=9

因此A1 屬于cluster1

?

?

???????? (2, 10)

??????? (5, 8)

???????? (1, 2)

?

?

Point

Dist Mean?cluster??1

Dist Mean?cluster?2

Dist Mean?cluster?3

Cluster

A1

(2, 10)

0

5

9

1

A2

(2, 5)

?

?

?

?

A3

(8, 4)

?

?

?

?

A4

(5, 8)

?

?

?

?

A5

(7, 5)

?

?

?

?

A6

(6, 4)

?

?

?

?

A7

(1, 2)

?

?

?

?

A8

(4, 9)

?

?

?

?


余下繼續(xù)計算,直到

?

?

???????? (2, 10)

??????? (5, 8)

???????? (1, 2)

?

?

Point

Dist Mean?cluster?1

Dist Mean?cluster?2

Dist Mean?cluster?3

Cluster

A1

(2, 10)

0

5

9

1

A2

(2, 5)

5

6

4

3

A3

(8, 4)

12

7

9

2

A4

(5, 8)

5

0

10

2

A5

(7, 5)

10

5

9

2

A6

(6, 4)

10

5

7

2

A7

(1, 2)

9

10

0

3

A8

(4, 9)

3

2

10

2


重新計算中心點

cluster1只有1個點,因此A1為中心點

cluster2的中心點為?( (8+5+7+6+4)/5,(4+8+5+4+9)/5 )=(6,6)。注意:這個點并不實際存在。

cluster3的中心點為( (2+1)/2, (5+2)/2 )= (1.5, 3.5)


圖形化的過程如下:


持續(xù)迭代,直到前后兩次迭代不發(fā)生變化為止,如下:



以上例子來源:http://www.google.com/url?sa=t&rct=j&q=&esrc=s&frm=1&source=web&cd=1&ved=0CDsQFjAA&url=http%3A%2F%2Ffaculty.uscupstate.edu%2Fatzacheva%2FSHIM450%2FKMeansExample.doc&ei=ZDMVT56XJOmoiQLeyLm9DQ&usg=AFQjCNHMUw4sLHM82Pu6cXc2DTSz-cz2pw


from:?http://blog.csdn.net/pennyliang/article/details/7207466

總結(jié)

以上是生活随笔為你收集整理的K-Means 聚类实例sample的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。