K-Means Clustering - Example - USC Upstate Facultyk-均值聚類樣本學(xué)院USC北部_第1頁
K-Means Clustering - Example - USC Upstate Facultyk-均值聚類樣本學(xué)院USC北部_第2頁
K-Means Clustering - Example - USC Upstate Facultyk-均值聚類樣本學(xué)院USC北部_第3頁
K-Means Clustering - Example - USC Upstate Facultyk-均值聚類樣本學(xué)院USC北部_第4頁
K-Means Clustering - Example - USC Upstate Facultyk-均值聚類樣本學(xué)院USC北部_第5頁
已閱讀5頁,還剩3頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、 K-Means Clustering ExampleK-Means Clustering ExampleWe recall from the previous lecture, that clustering allows for unsupervised learning. That is, the machine / software will learn on its own, using the data (learning set), and will classify the objects into a particular class for example, if our

2、class (decision) attribute is tumorType and its values are: malignant, benign, etc. - these will be the classes. They will be represented by cluster1, cluster2, etc. However, the class information is never provided to the algorithm. The class information can be used later on, to evaluate how accurat

3、ely the algorithm classified the objects.CurvatureTextureBloodConsumpTumorTypex10.81.2ABenignx20.751.4BBenignx30.230.4DMalignantx4.0.230.5DMalignantCurvatureTextureBloodConsumpTumorTypex10.81.2ABenignx20.751.4BBenignx30.230.4DMalignantx4.0.230.5DMalignant(learning set)CurvatureTextureBloodConsump0.8

4、0.231.20.4ABD.x1The way we do that, is by plotting the objects from the database into space. Each attribute is one dimension:CurvatureTextureBloodConsump0.80.231.20.4ABD.Cluster 1benignCluster 2malignant.After all the objects are plotted, we will calculate the distance between them, and the ones tha

5、t are close to each other we will group them together, i.e. place them in the same cluster.With the K-Means algorithm, we recall it works as follows:ExampleProblem: Cluster the following eight points (with (x, y) representing locations) into three clusters A1(2, 10) A2(2, 5) A3(8, 4) A4(5, 8) A5(7,

6、5) A6(6, 4) A7(1, 2) A8(4, 9). Initial cluster centers are: A1(2, 10), A4(5, 8) and A7(1, 2). The distance function between two points a=(x1, y1) and b=(x2, y2) is defined as: (a, b) = |x2 x1| + |y2 y1| . Use k-means algorithm to find the three cluster centers after the second iteration. Solution:It

7、eration 1 (2, 10) (5, 8) (1, 2)PointDist Mean 1Dist Mean 2Dist Mean 3ClusterA1(2, 10)A2(2, 5)A3(8, 4)A4(5, 8)A5(7, 5)A6(6, 4)A7(1, 2)A8(4, 9)First we list all points in the first column of the table above. The initial cluster centers means, are (2, 10), (5, 8) and (1, 2) - chosen randomly. Next, we

8、will calculate the distance from the first point (2, 10) to each of the three means, by using the distance function:pointmean1x1, y1x2, y2(2, 10) (2, 10) (a, b) = |x2 x1| + |y2 y1|(point, mean1) = |x2 x1| + |y2 y1| = |2 2| + |10 10| = 0 + 0 = 0pointmean2x1, y1x2, y2(2, 10) (5, 8) (a, b) = |x2 x1| +

9、|y2 y1|(point, mean2) = |x2 x1| + |y2 y1| = |5 2| + |8 10| = 3 + 2 = 5pointmean3x1, y1x2, y2(2, 10) (1, 2) (a, b) = |x2 x1| + |y2 y1|(point, mean2) = |x2 x1| + |y2 y1| = |1 2| + |2 10| = 1 + 8 = 9So, we fill in these values in the table: (2, 10) (5, 8) (1, 2)PointDist Mean 1Dist Mean 2Dist Mean 3Clu

10、sterA1(2, 10)0591A2(2, 5)A3(8, 4)A4(5, 8)A5(7, 5)A6(6, 4)A7(1, 2)A8(4, 9)So, which cluster should the point (2, 10) be placed in? The one, where the point has the shortest distance to the mean that is mean 1 (cluster 1), since the distance is 0.Cluster 1Cluster 2Cluster 3(2, 10)So, we go to the seco

11、nd point (2, 5) and we will calculate the distance to each of the three means, by using the distance function:pointmean1x1, y1x2, y2(2, 5) (2, 10) (a, b) = |x2 x1| + |y2 y1|(point, mean1) = |x2 x1| + |y2 y1| = |2 2| + |10 5| = 0 + 5 = 5pointmean2x1, y1x2, y2(2, 5) (5, 8) (a, b) = |x2 x1| + |y2 y1|(p

12、oint, mean2) = |x2 x1| + |y2 y1| = |5 2| + |8 5| = 3 + 3 = 6pointmean3x1, y1x2, y2(2, 5) (1, 2) (a, b) = |x2 x1| + |y2 y1|(point, mean2) = |x2 x1| + |y2 y1| = |1 2| + |2 5| = 1 + 3 = 4So, we fill in these values in the table:Iteration 1 (2, 10) (5, 8) (1, 2)PointDist Mean 1Dist Mean 2Dist Mean 3Clus

13、terA1(2, 10)0591A2(2, 5)5643A3(8, 4)A4(5, 8)A5(7, 5)A6(6, 4)A7(1, 2)A8(4, 9)So, which cluster should the point (2, 5) be placed in? The one, where the point has the shortest distance to the mean that is mean 3 (cluster 3), since the distance is 0.Cluster 1Cluster 2Cluster 3(2, 10)(2, 5)Analogically,

14、 we fill in the rest of the table, and place each point in one of the clusters:Iteration 1 (2, 10) (5, 8) (1, 2)PointDist Mean 1Dist Mean 2Dist Mean 3ClusterA1(2, 10)0591A2(2, 5)5643A3(8, 4)12792A4(5, 8)50102A5(7, 5)10592A6(6, 4)10572A7(1, 2)91003A8(4, 9)32102Cluster 1Cluster 2Cluster 3(2, 10)(8, 4)

15、(2, 5)(5, 8)(1, 2)(7, 5)(6, 4)(4, 9)Next, we need to re-compute the new cluster centers (means). We do so, by taking the mean of all points in each cluster.For Cluster 1, we only have one point A1(2, 10), which was the old mean, so the cluster center remains the same.For Cluster 2, we have ( (8+5+7+6+4)/5, (4+8+5+4+9)/5 ) = (6, 6)For Cluster 3, we have ( (2+1)/2, (5+2)/2 ) = (1.5, 3.5)The initial cluster centers are shown in red dot. The new cluster centers are sho

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論