当前位置:网站首页>【数据分析】基于 kmeans实现数据聚类分组含Matlab源码
【数据分析】基于 kmeans实现数据聚类分组含Matlab源码
2022-06-12 21:49:00 【Matlab科研工作室】
1 简介
从理论,设计程序和代码实现等方面,说明如何通过数据挖掘中K-均值聚类算法,利用Matlab的灵活编程功能进行探索性和优化性综合实验.以实验教学实践说明,为将创新思维和动手能力培养贯穿于实验教学的始终,利用Matlab仿真K-均值聚类具有较好的实际意义.
聚类是将数据集按照数据的相似性进行重新组合而成为多个类的过程。聚类与分类不同: 分类是一种监督学习方法, 在分类之前已经知道数据类的特性; 聚类是一种非监督学习方法, 在聚类之前不知道数据类的特性。在数据挖掘的实验教学中, 教师往往只重视聚类算法本身, 并没有真正理解聚类的本质, 只将聚类算法写成固定形式, 甚至只把不能变化的程序和预先给定的分好的数组进行聚类, 错误理解了聚类的本质,没有将灵活的算法和聚类的思想融入实验中。没有达到在实验中培养学生创新思想和能力的目的。


2 部分代码
function []=show(X,cidx,ctrs,varargin)%{show[X,cidx,ctrs] X为输入原始数据的矩阵,cidx,ctrs为k_meansnD返回的结果,它们分别是n次迭代的分组和质心坐标。show[X,cidx,ctrs,stp] 显示迭代次数为stp时候的分组情况。%}if nargin<3error('there is not enough input arguments >.<#~ ')elseif nargin==3idx=cidx(:,end); %如果输入变量是3个,idx赋成cidx的最后一列,也就是最后的分组情况。ctr=ctrs(:,:,end); %ctr被赋成ctrs的最后一页,也就是最后得到的质心坐标。elseif nargin==4stp=varargin{1};idx=cidx(:,stp);ctr=ctrs(:,:,stp);elseif nargin>4error('there is too many input arguments >.<#~ ')end %end ifk=size(ctrs,1);C=jet(k);d=size(X,2);if d==2for i=1:kplot(X(idx==i,1),X(idx==i,2),'.','color',C(i,:));hold on;plot(ctr(i,1),ctr(i,2),'kx')hold on;end %end forhold off;elseif d==3for i=1:kplot3(X(idx==i,1),X(idx==i,2),X(idx==i,3),'.','color',C(i,:));hold on;plot3(ctr(i,1),ctr(i,2),ctr(i,3),'kx')hold on;end %end forhold off;end %end ifgrid onend %end function
3 仿真结果

4 参考文献
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
边栏推荐
- Gzip compression decompression
- 最近公共祖先问题你真的学会了吗?
- Xingda easy control modbustcp to profibusdp
- SQL调优指南笔记10:Optimizer Statistics Concepts
- Oracle数据库中查询执行计划的权限
- Ansible foundation and common modules (I)
- Open source background management system suitable for outsourcing projects
- What is embedded
- My struggle: my years in foreign enterprises (1)
- PE安装win10系统
猜你喜欢

Oracle LiveLabs实验:Introduction to Oracle Spatial

“Oracle数据库并行执行”技术白皮书读书笔记

建立高可用的数据库

Open source background management system suitable for outsourcing projects

Preliminary use of jvisualvm

Ansible playbook和变量(二)

SQL调优指南笔记6:Explaining and Displaying Execution Plans

NPOI 创建Word

最近公共祖先问题你真的学会了吗?

PCB package download website recommendation and detailed usage
随机推荐
talent showing itself! Oceanbase was selected into the 2021 "sci tech innovation China" open source innovation list
Kdd2022 | graphmae: self supervised mask map self encoder
Can tonghuashun open an account? Is it safe to open an account in tonghuashun? How to open a securities account
Ansible roles project case (IV)
[Jianzhi offer] Jianzhi offer 05 Replace spaces
What are thread scheduler and timeslicing?
How to implement a simple publish subscribe mode
孙老师版本JDBC(2022年6月12日21:34:25)
Ansible playbook和Ansible Roles(三)
My struggle: my years in foreign enterprises (1)
SQL tuning guide notes 8:optimizer access paths
2023届校园招聘正式开启!OceanBase 想和你在这个春天约一场面试
JVisualVM初步使用
SQL调优指南笔记16:Managing Historical Optimizer Statistics
Oracle LiveLabs实验:Introduction to Oracle Spatial
A puzzle about + =
SQL tuning guide notes 13:gathering optimizer statistics
Thread safe level
Kotlin collaboration process - flow
在同花顺开户证券安全吗,证券开户怎么开户流程