




已閱讀5頁,還剩16頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
k-Means ClusteringOn this pageIntroduction to k-Means ClusteringCreate Clusters and Determine SeparationDetermine the Correct Number of ClustersAvoid Local MinimaIntroduction to k-Means Clusteringk-means clustering is a partitioning method. The functionkmeanspartitions data intokmutually exclusive clusters, and returns the index of the cluster to which it has assigned each observation. Unlike hierarchical clustering, k-means clustering operates on actual observations (rather than the larger set of dissimilarity measures), and creates a single level of clusters. The distinctions mean that k-means clustering is often more suitable than hierarchical clustering for large amounts of data.kmeanstreats each observation in your data as an object having a location in space. It finds a partition in which objects within each cluster are as close to each other as possible, and as far from objects in other clusters as possible. You can choose from five different distance measures, depending on the kind of data you are clustering.Each cluster in the partition is defined by its member objects and by its centroid, or center. The centroid for each cluster is the point to which the sum of distances from all objects in that cluster is minimized.kmeanscomputes cluster centroids differently for each distance measure, to minimize the sum with respect to the measure that you specify.kmeansuses an iterative algorithm that minimizes the sum of distances from each object to its cluster centroid, over all clusters. This algorithm moves objects between clusters until the sum cannot be decreased further. The result is a set of clusters that are as compact and well-separated as possible. You can control the details of the minimization using several optional input parameters tokmeans, including ones for the initial values of the cluster centroids, and for the maximum number of iterations.Create Clusters and Determine SeparationThe following example explores possible clustering in four-dimensional data by analyzing the results of partitioning the points into three, four, and five clusters.Note Because each part of this example generates random numbers sequentially, i.e., without setting a new state, you must perform all steps in sequence to duplicate the results shown. If you perform the steps out of sequence, the answers will be essentially the same, but the intermediate results, number of iterations, or ordering of the silhouette plots may differ.First, load some data:rng(default); % For reproducibilityload kmeansdata;size(X)ans = 560 4Even though these data are four-dimensional, and cannot be easily visualized,kmeansenables you to investigate whether a group structure exists in them. Callkmeanswithk, the desired number of clusters, equal to3. For this example, specify the city block distance measure, and use the default starting method of initializing centroids from randomly selected data points.idx3 = kmeans(X,3,distance,city);To get an idea of how well-separated the resulting clusters are, you can make a silhouette plot using the cluster indices output fromkmeans. The silhouette plot displays a measure of how close each point in one cluster is to points in the neighboring clusters. This measure ranges from +1, indicating points that are very distant from neighboring clusters, through 0, indicating points that are not distinctly in one cluster or another, to -1, indicating points that are probably assigned to the wrong cluster.silhouettereturns these values in its first output.silh3,h = silhouette(X,idx3,city);set(get(gca,Children),FaceColor,.8 .8 1)xlabel(Silhouette Value)ylabel(Cluster)From the silhouette plot, you can see that most points in the second cluster have a large silhouette value, greater than 0.6, indicating that the cluster is somewhat separated from neighboring clusters. However, the third cluster contains many points with low silhouette values, and the first contains a few points with negative values, indicating that those two clusters are not well separated.Determine the Correct Number of ClustersIncrease the number of clusters to see ifkmeanscan find a better grouping of the data. This time, use the optionaldisplayparameter to print information about each iteration.idx4 = kmeans(X,4, dist,city, display,iter); iter phase num sum 1 1 560 2077.43 2 1 51 1778.64 3 1 3 1771.1 4 2 0 1771.1Best total sum of distances = 1771.1Notice that the total sum of distances decreases at each iteration askmeansreassigns points between clusters and recomputes cluster centroids. In this case, the second phase of the algorithm did not make any reassignments, indicating that the first phase reached a minimum after five iterations. In some problems, the first phase might not reach a minimum, but the second phase always will.A silhouette plot for this solution indicates that these four clusters are better separated than the three in the previous solution.silh4,h = silhouette(X,idx4,city);set(get(gca,Children),FaceColor,.8 .8 1)xlabel(Silhouette Value)ylabel(Cluster)A more quantitative way to compare the two solutions is to look at the average silhouette values for the two cases.cluster3 = mean(silh3)cluster4 = mean(silh4)cluster3 = 0.5352cluster4 = 0.6400Finally, try clustering the data using five clusters.idx5 = kmeans(X,5,dist,city,replicates,5);silh5,h = silhouette(X,idx5,city);set(get(gca,Children),FaceColor,.8 .8 1)xlabel(Silhouette Value)ylabel(Cluster)mean(silh5)ans = 0.5266This silhouette plot indicates that this is probably not the right number of clusters, since two of the clusters contain points with mostly low silhouette values. Without some knowledge of how many clusters are really in the data, it is a good idea to experiment with a range of values fork.Avoid Local MinimaLike many other types of numerical minimizations, the solution thatkmeansreaches often depends on the starting points. It is possible forkmeansto reach a local minimum, where reassigning any one point to a new cluster would increase the total sum of point-to-centroid distances, but where a better solution does exist. However, you can use the optionalreplicatesparameter to overcome that problem.For four clusters, specify five replicates, and use thedisplayparameter to print out the final sum of distances for each of the solutions.idx4,cent4,sumdist = kmeans(X,4,dist,city,. display,final,replicates,5);Replicate 1, 4 iterations, total sum of distances = 1771.
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 財(cái)務(wù)業(yè)務(wù)工作目標(biāo)設(shè)定計(jì)劃
- 計(jì)算機(jī)圖形處理技術(shù)試題及答案
- 2025屆深圳市重點(diǎn)中學(xué)七下數(shù)學(xué)期末教學(xué)質(zhì)量檢測模擬試題含解析
- 預(yù)測2025年VB考試題型及試題與答案
- 工作重心和優(yōu)先級排列計(jì)劃
- 語言能力提升活動(dòng)計(jì)劃
- 水務(wù)行業(yè)安保工作總結(jié)與建議計(jì)劃
- 提升班級文化品位的具體方法計(jì)劃
- 法官職業(yè)的基本素養(yǎng)試題及答案
- 2024年西藏自治區(qū)財(cái)政廳下屬事業(yè)單位真題
- 超聲引導(dǎo)下的星狀神經(jīng)節(jié)阻滯
- 天津師范大學(xué)與韓國世翰大學(xué)入學(xué)綜合素質(zhì)題目
- 中國蠶絲綢文化智慧樹知到期末考試答案章節(jié)答案2024年浙江大學(xué)
- MOOC 學(xué)術(shù)英語寫作-東南大學(xué) 中國大學(xué)慕課答案
- 地鐵盾構(gòu)管片常見質(zhì)量問題分析
- 南瓜種植PPT演示課件(PPT 46頁)
- 消防維護(hù)與保養(yǎng)(通用)ppt課件
- 浙江理工大學(xué)研究生培養(yǎng)方案專家論證意見表
- T∕CADERM 3033-2020 創(chuàng)傷中心創(chuàng)傷復(fù)蘇單元內(nèi)醫(yī)師 站位及分工規(guī)范
- 高等數(shù)學(xué)(下)無窮級數(shù)PPT通用PPT課件
- 大傾角皮帶輸送機(jī)設(shè)計(jì)(全套圖紙)
評論
0/150
提交評論