k-means

  • partitioning a dataset into k distinct clusters based on similarity measures. It aims to minimize the within-cluster sum of squares (WCSS) or the average squared distance between data points and their assigned cluster centroids

  • 通过样本间的相似性对数据集进行聚类,使类内差距最小化,类间差距最大化

过程

  • 选择初始化的 k 个样本作为初始聚类中心

  • 针对数据集中每个样本, 计算它到 k 个聚类中心的距离并将其分到距离最小的聚类中心所对应的类中

  • 针对每个类别 ,重新计算它的聚类中心 (即属于该类的所有样本的质心);

  • 重复上面 2 3 两步操作,直到达到某个中止条件(迭代次数、最小误差变化等

评价

  • 可以通过衡量簇内差异来衡量聚类的效果:Inertia

    • a.它的计算太容易受到特征数目的影响。

    • b.它不是有界的,Inertia是越小越好,但并不知道何时达到模型的极限,能否继续提高。

    • c.它会受到超参数K的影响,随着K越大,Inertia必定会越来越小,但并不代表模型效果越来越好。

    • d.Inertia 对数据的分布有假设,它假设数据满足凸分布,并且它假设数据是各向同性的,所以使用Inertia作为评估指标,会让聚类算法在一些细长簇、环形簇或者不规则形状的流形时表现不佳。

  • 轮廓系数

PCA

  • explained variance ratio

  • create new uncorrelated variables that successively maximize variance by solving an eigenvalue/eigenvector problem.

  • reduce the dimensionality of dataset, increase interpretability while minimize information loss

  • pros: no need of prior; reduce overfitting (by reduce #variables in the dataset); visualizable

  • cons: data standardization is a prerequisite; information loss

问答

  • cons

    • 对outlier敏感

  • k means 如何选择k

  • 怎么判断clustering效果好不好

    • 聚类评价指标: Purity, NMI, RI, Precision(查准率), Recall(查全率), F, ARI, Accuracy(正确率)

  • k-means和KNN的区别

    • k-means无监督,KNN有监督

  • signal-to-variance ratio

  • K-means为什么是收敛的

  • K-means 怎么初始化 K-means++

  • EM方法为什么是收敛的

  • Any acceleration algorithm for PCA

    • PCA involves computing the eigenvectors and eigenvalues of the covariance matrix or performing Singular Value Decomposition (SVD), both of which can be time-intensive.

code

时间复杂度: O(tkmn) ,t 为迭代次数,k 为簇的数目,n 为样本点数,m 为样本点维度 空间复杂度: O(m(n+k)) ,k 为簇的数目,m 为样本点维度,n 为样本点数

参考

Last updated