K-Means分群技术,能够将不同的数据进行很好的分类,并且它能够很快的收敛,从而使我们能够迅速的得到结果。
K-Means演算法:
(1)最初的设定依照分类的个数k,以random随机产生k个圆心坐标{c1(m),c2(m),c3(m)...ck(m)}
(2)计算所有培训数据与圆心坐标的距离,并进行第一次分群。计算距离的时候使采用欧几里得方法,进行第一次分群是根据距离来判断,选择与每个圆心坐标距离最小的,例如:第一个培训数据计算结果是与圆心3的距离最短,那么低一个培训数据属于群3,其它依次类推。
(3)重新计算圆心坐标,计算的方法举个例子,比如:计算的结果属于群3的,总共有3笔资料,这三个资料分布用a1,a2,a3代表,那么新圆心的横坐标就是a1,a2,a3三个资料的横坐标的和除以3(总共3笔资料),纵坐标是a1,a2,a3三个资料的纵坐标的和除以3(总共3笔资料),从而得到新的圆心的坐标。
(4)测试是否收敛。
训练数据如下:Pattern[1]=(0,0) Pattern[2]=(1,0) Pattern[3]=(0,1)
Pattern[4]=(2,1) Pattern[5]=(1,2) Pattern[6]=(2,2)
Pattern[7]=(2,0) Pattern[8]=(0,2) Pattern[9]=(7,6)
Pattern[10]=(7,7) Pattern[11]=(7,8) Pattern[12]=(8,6)
Pattern[13]=(8,7) Pattern[14]=(8,8) Pattern[15]=(8,9)
Pattern[16]=(9,7) Pattern[17]=(9,8) Pattern[18]=(9,9)
Step 1.随机产出三个圆心坐标:ClusterCenter[1]=(0,0) ClusterCenter[2]=(1,0) ClusterCenter[3]=(2,0)
Step 2.计算各训练样本与分类圆心座标的距离
循链范例 | Cluster[1] | Cluster[2] | Cluster[3] | 指定聚类 |
Pattern[1] | 0.0 | 1.0 | 2.0 | 1 |
Pattern[2] | 1.0 | 0.0 | 1.0 | 2 |
Pattern[3] | 1.0 | 1.4 | 2.2 | 1 |
Pattern[4] | 2.2 | 1.4 | 1.0 | 3 |
Pattern[5] | 2.2 | 2.0 | 2.2 | 2 |
Pattern[6] | 2.8 | 2.2 | 2.0 | 3 |
Pattern[7] | 2.0 | 1.0 | 0.0 | 3 |
Pattern[8] | 2.0 | 2.2 | 2.8 | 1 |
Pattern[9] | 9.2 | 8.5 | 7.8 | 3 |
Pattern[10] | 9.9 | 9.2 | 8.6 | 3 |
Pattern[11] | 10.6 | 10.0 | 9.4 | 3 |
Pattern[12] | 10.0 | 9.2 | 8.5 | 3 |
Pattern[13] | 10.6 | 9.9 | 9.2 | 3 |
Pattern[14] | 11.3 | 10.6 | 10.0 | 3 |
Pattern[15] | 12.0 | 10.4 | 10.8 | 2 |
Pattern[16] | 11.4 | 10.6 | 9.9 | 3 |
Pattern[17] | 12.0 | 11.3 | 10.6 | 3 |
Pattern[18] | 12.7 | 12.0 | 11.4 | 3 |
重新计算聚类圆心坐标
ClusterCenter[1]=(0.0,1.0);
ClusterCenter[2]=(3.33,3.67);
ClusterCenter[3]=(6.5,5.75);
再次计算各训练样本与分类圆心座标的距离
循链范例 | Cluster[1] | Cluster[2] | Cluster[3] | 指定聚类 |
Pattern[1] | 1.0 | 5.0 | 8.7 | 1 |
Pattern[2] | 1.4 | 4.3 | 8.0 | 1 |
Pattern[3] | 0.0 | 4.3 | 8.1 | 1 |
Pattern[4] | 2.0 | 3.0 | 6.5 | 1 |
Pattern[5] | 1.4 | 2.9 | 6.7 | 1 |
Pattern[6] | 2.2 | 2.1 | 5.9 | 2 |
Pattern[7] | 2.2 | 3.9 | 7.3 | 1 |
Pattern[8] | 1.0 | 3.7 | 7.5 | 1 |
Pattern[9] | 8.6 | 4.3 | 0.6 | 3 |
Pattern[10] | 9.2 | 5.0 | 1.3 | 3 |
Pattern[11] | 9.9 | 5.7 | 2.3 | 3 |
Pattern[12] | 9.4 | 5.2 | 1.5 | 3 |
Pattern[13] | 10.0 | 5.7 | 2.0 | 3 |
Pattern[14] | 10.6 | 6.4 | 2.7 | 3 |
Pattern[15] | 11.3 | 7.1 | 3.6 | 3 |
Pattern[16] | 10.8 | 6.6 | 2.8 | 3 |
Pattern[17] | 11.4 | 7.1 | 3.4 | 3 |
Pattern[18] | 12.0 | 7.8 | 4.1 | 3 |
重新计算聚类圆心坐标
ClusterCenter[1]=(0.86,0.86);
ClusterCenter[2]=(2.0,2.0);
ClusterCenter[3]=(8.0,7.5);
再次计算各训练样本与分类圆心座标的距离
循链范例 | Cluster[1] | Cluster[2] | Cluster[3] | 指定聚类 |
Pattern[1] | 1.2 | 2.8 | 11.0 | 1 |
Pattern[2] | 0.9 | 2.2 | 10.3 | 1 |
Pattern[3] | 0.9 | 2.2 | 10.3 | 1 |
Pattern[4] | 1.1 | 1.0 | 8.8 | 2 |
Pattern[5] | 1.1 | 1.0 | 8.9 | 2 |
Pattern[6] | 1.6 | 0.0 | 8.1 | 2 |
Pattern[7] | 1.4 | 2.0 | 9.6 | 1 |
Pattern[8] | 1.4 | 2.0 | 9.7 | 1 |
Pattern[9] | 8.0 | 6.4 | 1.8 | 3 |
Pattern[10] | 8.7 | 7.1 | 1.1 | 3 |
Pattern[11] | 9.4 | 7.8 | 1.1 | 3 |
Pattern[12] | 8.8 | 7.2 | 1.5 | 3 |
Pattern[13] | 9.4 | 7.8 | 0.5 | 3 |
Pattern[14] | 10.1 | 8.5 | 0.5 | 3 |
Pattern[15] | 10.8 | 9.2 | 1.5 | 3 |
Pattern[16] | 10.2 | 8.6 | 1.1 | 3 |
Pattern[17] | 10.8 | 9.2 | 1.1 | 3 |
Pattern[18] | 11.5 | 9.9 | 1.8 | 3 |
重新计算聚类圆心坐标
ClusterCenter[1]=(0.6,0.6);
ClusterCenter[2]=(1.67,1.67);
ClusterCenter[3]=(8.0,7.5);
循链范例 | Cluster[1] | Cluster[2] | Cluster[3] | 指定聚类 |
Pattern[1] | 0.8 | 2.4 | 11.0 | 1 |
Pattern[2] | 0.7 | 1.8 | 10.3 | 1 |
Pattern[3] | 0.7 | 1.8 | 10.3 | 1 |
Pattern[4] | 1.5 | 0.7 | 8.8 | 2 |
Pattern[5] | 1.5 | 0.7 | 8.9 | 2 |
Pattern[6] | 2.0 | 0.5 | 8.1 | 2 |
Pattern[7] | 1.5 | 1.7 | 9.6 | 1 |
Pattern[8] | 1.5 | 1.7 | 9.7 | 1 |
Pattern[9] | 8.4 | 6.9 | 1.8 | 3 |
Pattern[10] | 9.1 | 7.5 | 1.1 | 3 |
Pattern[11] | 9.8 | 8.3 | 1.1 | 3 |
Pattern[12] | 9.2 | 7.7 | 1.5 | 3 |
Pattern[13] | 9.8 | 8.3 | 0.5 | 3 |
Pattern[14] | 10.5 | 9.0 | 0.5 | 3 |
Pattern[15] | 11.2 | 9.7 | 1.5 | 3 |
Pattern[16] | 10.6 | 9.1 | 1.1 | 3 |
Pattern[17] | 11.2 | 9.7 | 1.1 | 3 |
Pattern[18] | 11.9 | 10.4 | 1.8 | 3 |
重新计算聚类圆心坐标
ClusterCenter[1]=(0.6,0.6);
ClusterCenter[2]=(1.67,1.67);
ClusterCenter[3]=(8.0,7.5);
聚类圆心座标不再改变,演算法达到收敛,因此决定最后的聚类圆心座标为
ClusterCenter[1]=(0.6,0.6);
ClusterCenter[2]=(1.67,1.67);
ClusterCenter[3]=(8.0,7.5);
分享到:
相关推荐
针对传统的K-means算法对初始聚类中心取值敏感和易陷入局部最优解等缺点,提出一种带时间因子的改进粒子群优化(Particle Swarm Optimization,PSO)聚类算法。首先在PSO算法中引入反映时间效应的动态调整时间因子,以...
matlab代码粒子群算法Hybrid-K-means-Pso(MATLAB) K-Means的高级版本,使用粒子群算法对高维数据集进行聚类,可以更快地收敛到最佳解决方案。 “聚类”是一种用于对数据集中的元素进行分区的技术,以便将相似的...
一种改进的简化均值粒子群K-means聚类算法.docx
基于改进量子粒子群的K-means聚类算法及其应用.pdf
一种实现微博兴趣挖掘的粒子群优化k-means算法.pdf
聚类分析法是理想的多变量统计技术,主要有分层聚类法和迭代聚类法。 聚类分析也称群分析、点群分析,是研究分类的一种多元统计方法。
基于kmeans的定位算法,对于研究无线传感器定位算法的改进,涉及到传感器的分群技术介绍
1.版本:matlab2014/2019a,内含运行结果,不会运行可私信 2.领域:智能优化算法、神经网络预测、信号处理、元胞自动机、图像...5.博客介绍:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可si信
单击下载代码。 KMeans集群简介 是一种迭代算法,广泛用于所有数据分析中,用于在称为聚类的数据中查找相似性组。 这是一种无监督的学习技术。 它试图通过相似性将群体中的个体... K均值将质心移动到群集中各个点的
针对现有的入侵检测对未知攻击检测率和误检率方面的不足...结果表明,蚁群聚类算法的检测率和误报率较K-means聚类算法有明显改善,因此,采用蚁群聚类算法的入侵检测系统具有较好地自动检测入侵并防止未知攻击的特点。
完成评分矩阵缺失项填充后,基于二分[k]-means聚类算法将偏好、兴趣特征相似的对象划分到同一个子群中,在目标用户所属的子群中基于选定的协同过滤算法为用户产生推荐列表,提高了推荐效率和准确性。在MovieLens和...
在研究了基本蚁群聚类模型、信息嫡以及几个经典的聚类分析算法的基础上,针对传统K-means算法的不足,首先提出了一种基于信息素的k-means改进算法,该算法以基于信息素的转移概率为判断标准来进行聚类,减少了算法的参数...
CluStream 是基于 k-means 算法的。这些算法不能够发现任 意形状的簇以及不能处理离群点。 解决上述问题,本文提出了 而且, 它需要预先知道 k 值和用户指定的时间窗口。 为了 分将数据映射到一个网格, D-Stream 算法,...
算法先利用K-means与细菌觅食算法相结合的聚类技术判断蚁群状态,进而动态调整算法参数,使其快速收敛到全局最优解附近,再依据混沌理论的特点来调整参数,使其跳出局部最优。最后,再利用2-opt算法对最优解进行优化...
2.3 K-means聚类算法 3 系统需求分析 3.1 系统功能性需求分析 3.1.1 系统功能分析 3.1.2 用户角色分析 3.2 系统非功能性需求分析 3.2.1 性能需求 3.2.2 可靠性需求 4 系统设计 4.1 系统总体架构设计 4.2 系统功能...
11 K-均值分群法,阶层分群法 k-Means Clustering, Hierarchical Clustering 12 案例:零售营销规划 Case: Retail Merchandising 13 期中考试 Midterm Exam 14 主成分分析 Principal Components 例一,长子...
提出了一种求解TSP问题的有效算法――蚁群优化算法。该算法通过模拟蚁群搜索食物的过程,求解TSP问题。算法的主要特点是,正反馈、分布式计算、与某种启发式算法相结合。并给出了算法原理及流程;最后用计算机仿真...
两步法是解决稀疏信号欠定盲分离的一种常用方法,通常首先利用K-means聚类算法估计混叠矩阵,然后利用最短路径法恢复源信号。在使用K-means聚类算法时要求知道源信号的数目,而现实中往往不知道源信号的数目,需要对...
但是,FCM聚类和K-means算法的结果均基于主要参数浓度,确定了3个聚类组并产生了聚类中心(原型)。 基于聚类分类,随着聚类数从1增加到3,显着的水质恶化。但是,聚类分组可用于识别物理,化学和生物过程,从而...