下载此文档

K-modes算法 matlab实现.docx


文档分类:IT计算机 | 页数:约5页 举报非法文档有奖
1/5
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/5 下载此文档
文档列表 文档介绍

K-modes算法 matlab实现
function [ resultLabel ] = Kmodes( k,dataSet) %KMODES Summary of this functio 页
%更新中心点,进展下一次划分,直到目标函数收敛 while(true)
iteratorNum=iteratorNum+1;
newcenter=updataCenters(k,resultLabel,dataS);
for i=1:row
data1=dataS(i,:);
selectCluster=zeros(1,k); for j=1:k
data2=newcenter(j,:);
selectCluster(1,j)=calculateDis(data1,data2);
end
[minx tlabel]=min(selectCluster); resultLabel(i,1)=tlabel; end
objValue=calculateObjectFunction(k,resultLabel,dataS,newcenter);
if((size(objValueVector,2)>0)&&(objValue==objValueVector(1,size(objValueVector,2)))); break; end
objValueVector=[objValueVector objValue]; end
t2=clock;
time=etime(t2,t1)
iterNum=iteratorNum

%计算两个数据之间的相异度
function [dis]=calculateDis(p1,p2) dis=0;










for ii=1:size(p1,2)
if(p1(1,ii)~=p2(1,ii)) dis=dis+1; end end end
%更新中心点 function
[newCenters]=updataCenters(k,resultLabel,data)
newCenters=zeros(k,size(data,2)); for ii=1:k
tempData=[];
for jj=1:size(resultLabel,1)

K-modes算法 matlab实现 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数5
  • 收藏数0 收藏
  • 顶次数0
  • 上传人圭圭
  • 文件大小31 KB
  • 时间2022-04-26