關於如何選擇Kmeans等聚類算法中的聚類中心個數,主要有以下方法(譯自維基):
1. 最簡單的方法:K≈sqrt(N/2)
2. 拐點法:把聚類結果的F-test值(類間Variance和全局Variance的比值)對聚類個數的曲線畫出來,選擇圖中拐點
3. 基於Information Critieron的方法:如果模型有似然函數(如GMM),用BIC、DIC等決策;即使沒有似然函數,如KMean,也可以搞一個假似然出來,例如用GMM等來代替
4. 基於信息論的方法(Jump法),計算一個distortion函數對K值的曲線,選擇其中的jump點
5. Silhouette法
6. 交叉驗證
7. 特別地,在文本中,如果詞頻矩陣為m*n維度,其中t個不為0,則K≈m*n/t
8. 核方法:構造Kernal矩陣,對其做eigenvalue decomposition,通過結果統計Compactness,獲得Compactness—K曲線,選擇拐點
另外,關於何如選擇初始點,一般選擇data cloud中相聚較遠的點,例如SPSS定義了兩個規則來尋找這樣的點:
首先隨機選K個初始點,然后對其余每個點
- a) If the case is farther from the centre closest to it than the distance between two most close to each other centres, the case substitutes that centre of the latter two to which it is closer.
- b) If the case is farther from the centre 2nd closest to it than the distance between the centre closest to it and the centre closest to this latter one, the case substitutes the centre closest to it.