基于MATLAB的KMEANS聚类程序说明书_第1页
基于MATLAB的KMEANS聚类程序说明书_第2页
基于MATLAB的KMEANS聚类程序说明书_第3页
基于MATLAB的KMEANS聚类程序说明书_第4页
基于MATLAB的KMEANS聚类程序说明书_第5页
已阅读5页,还剩7页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1基于MATLAB的KMEANS聚类程序程序和数据如下洗手CODE洗手KMEANS算法主程序K4BEEFX121262133805115020440931607634001250275229593018130883308505311042539300588018083114101244068110989132008000241290109748107771143801996001392721301909011840101311467138200142702239114971941403035034642699322556016370013930311014170088801791284030180900965008171011820372016380034908968102600101302369111121880200291015061190722041010600216710114080290131700153231715010410333800321097181963400305032591037708889028340230108989101850028900213298150479802245030850857609231027520009131356000261213807733344702241802014015562914317951019920214634961249690012101315293410107107712089112810500884002870127931006206770200201303082092172401548035162850003196013590117928679013650570207626282450131200881013050832213014038370240026063014310188000487313410085400359020800689320854032500100710894172710017606553329851001130066600802103712272401044039822803202737073911027726856006191106610485294450160200019000931200421302016500341332505192790446202405120800822201671015762827401515096361067528190186260270200026105071777601421009992894601446016450307110105109730024101628291380340400627012863064600008038190154112531198300077402413114862044000582006503140101447065800956229591015980658111937292190363701538020852894822745023320031232972002190028801436412737076480064300858106900810802723032310590807508054560019005808205730165801709282272246102255036840617417654039990412532587193100202100800109991885200475005852739502585084410998712223105420248002795292120060500259025913159822631017460148508476187600289400354292052241804137024992765621768007190184808698102490208400008114440778704958036761071110450004770403005350181100037701622090761884501121057002788702119005660012012567092740110401581529946020860816906662105361981800631025812846502222027450199728516016490756608616324700077001173010922932200631000620051127919004380193505023098941947500146003902965901300011440341027322004271075809718148520859200503013732884521465005330104431470005360107303323294232157200505011803068303434065630896013215209510155703994076811207502781023720696412360033420166206382082040258703344302330149602607004000895209872000190313808172068140069101009633032005710024301405078101901303996073740903008646014980111208461092610129500727281822081801430005472929523846002440140010587222270125000957307551736500511015001307608791037200033128252003660679007374265510187503222004832965901585040130140232859015460010401781066791199901396031951020512226018500005030091001860911109663303390137709662106640895219594032210357928481019630142800382107962135300792064910873208985000490006810620214780127503553734509199750128501575322800064011513082350665409402005770017532100027620105300626307932004302948004111359619481001670395831267018010222801179079790989202673047342558017623010490052109172106210082601501078171165801922008033174721442014720341128476180560068001536061751434901970010850730819656026020280110310105530292801647292510209500582018130982712720022250256310830111580040501181287440019503811014553166319241004550168410734076810472501976BEEF8N,DSIZEXBEEFBNROUNDN/KRANDBEEF第一个随机数在前1/K的范围内NCXBN,BEEFX2BN,BEEFX3BN,BEEFX4BN,BEEF初始聚类中心CID,NR,CENTERSKMEANSX,K,NC调用KMEANS函数FORI1150,IFCIDI1,PLOTXI,1,XI,2,R显示第一类HOLDONELSEIFCIDI2,PLOTXI,1,XI,2,B显示第二类HOLDONELSEIFCIDI3,PLOTXI,1,XI,2,G显示第三类HOLDONELSEIFCIDI4,PLOTXI,1,XI,2,K显示第四类HOLDONEND9ENDENDENDENDSTRT红色为第一类;BEEF蓝色为第二类;BEEF绿色为第三类;BEEF黑色为第四类BEEFTEXT4,36,STRTBEEF函数如下洗手CODE洗手BASICKMEANSM主类FUNCTIONCID,NR,CENTERSKMEANSX,K,NCN,DSIZEXBEEF设置CID为分类结果显示矩阵CIDZEROS1,NBEEFMAKETHISDIFFERENTTOGETTHELOOPSTARTEDOLDCIDONES1,NBEEFTHENUMBERINEACHCLUSTERNRZEROS1,KBEEFSETUPMAXIMUMNUMBEROFITERATIONSMAXGN100BEEFITER1BEEFWHILEITERMAXGN计算每个数据到聚类中心的距离FORI1N10DISTSUMREPMATXI,K,1NC2,2BEEFM,INDMINDISTBEEF将当前聚类结果存入CID中CIDIINDBEEFENDFORI1K找到每一类的所有数据,吃饭计算他们的平均值,吃饭作为下次计算的聚类中心INDFINDCIDIBEEFNCI,MEANXIND,BEEF统计每一类的数据个数NRILENGTHINDBEEFENDITERITER1BEEFENDNOWCHECKEACHOBSERVATIONTOSEEIFTHEERRORCANBEMINIMIZEDSOMEMORELOOPTHROUGHALLPOINTSMAXITER2BEEFITER1BEEFMOVE1BEEFWHILEITERMAXITERBEEF对所有的数据进行再次判断,吃饭寻求最佳聚类结果11FORI1NDISTSUMREPMATXI,K,1NC2,2BEEFRCIDIBEEF将当前数据属于的类给RDADJNR/NR1DISTBEEF计算调整后的距离M,INDMINDADJBEEF早到该数据距哪个聚类中心最近IFINDR如果不等则聚类中心移动CIDIINDBEEF将新的聚类结果送给CIDICFINDCIDINDBEEF重新计算调整当前类别的聚类中心NCIND,MEA

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论