ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

ML: K-means Clustering

2022-07-16 17:35:51  阅读:188  来源: 互联网

标签:Clustering function different means ML centroids distortion mu cluster


Source: Coursera Machine Learning provided by Stanford University Andrew Ng - Machine Learning | Coursera


Unsupervised Learning - Clustering - K-means Algorithm

notations:

$K$: the number of clusters

$\mu_k$: the $k$-th cluster centroid, $\mu_k \in \mathbb{R}^n$

$c^{(i)}$: the index of the nearest centroid to the $i$-th example $x^{(i)}$, $c^{(i)} \in [1,K]$

algorithm process:

randomly initialize $K$ cluster centroids

repeat{

  for $i=1$ to $m$: update $c^{(i)}$

  for $k=1$ to $K$: $\mu _k$ := mean of points assigned to cluster $k$

}

distortion function:

The optimization objective of the K-means algorithm is the distortion function:

$$ J(c^{(1)},c^{(2)},\cdots,c^{(m)},\mu_1,\mu_2,\cdots,\mu_k) = \frac{1}{m} \sum_{i=1}^{m}\left\| x^{(i)} - \mu_{c^{(i)}}\right\|^2 $$

In each iteration, the first step is minimizing $J$ with respect to $c^{(i)}$s, and the second step is minimizing $J$ with respect to $\mu_k$s. Thus, the distortion function either decreases or stays the same (convergence) after each iteration.

random initialization:

One common way to initialize the cluster centroids is to randomly select $K$ points as centroids. However, different initial centroids may result in different answers, in other words, the algorithm may end up in different local minimums: 

local minimum

To deal with this, run the algorithm multiple times with different random initial centroids, and choose the result with the minimum distortion function.

choosing the number of clusters:

One way is called the "elbow" method - choose the $k$ before which the distortion function decreases rapidly and after which it decreases much more slowly.

elbow

Another way is to choose $K$ according to the later performance of the problem if the classification is for other later purposes.

标签:Clustering,function,different,means,ML,centroids,distortion,mu,cluster
来源: https://www.cnblogs.com/ms-qwq/p/16484690.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有