资源描述:
《属性约简(MATLAB算法)有实例有讲解》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、粗糙集 属性约简题目: SARS诊断注:这是我学粗糙集时老师给的作业 U干咳呼吸困难 血液检测高烧38度 X射线浓痰血细胞多寒战肌肉酸痛乏力胸膜痛头痛非典111 1100001101120 0 00000000000310 1000000100040 0 0111101011051 0 01111101100601 01111110010710 00111001110811 11000011011910 11100011011101 1 11000011011111 0 11100011011121 0 11100
2、011011属性约简的顺序如下:求正域、生成未经处理的区分矩阵、对区分矩阵进行化简、求核、对已经处理过的区分矩阵进行属性约简。约简后的决策表有26行,所有12个属性都是正域中的属性,核为空 程序:%main.mtic;a=[1,1,1,1,0,0,0,0,1,1,0,1; 0,0,0,0,0,0,0,0,0,0,0,0; 1,0,1,0,0,0,0,0,0,1,0,0; 0,0,0,1,1,1,1,0,1,0,1,1; 1,0,0,1,1,1,1,1,0,1,1,0; 0,1,0,1,1,1,1
3、,1,1,0,0,1; 1,0,0,0,1,1,1,0,0,1,1,1; 1,1,1,1,0,0,0,0,1,1,0,1; 1,0,1,1,1,0,0,0,1,1,0,1; 1,1,1,1,0,0,0,0,1,1,0,1; 1,0,1,1,1,0,0,0,1,1,0,1; 1,0,1,1,1,0,0,0,1,1,0,1];d=[1;0;0;0;0;0;0;1;1;1;1;1];pos=posCD(a,d);dismat=dismatrix(a,d,pos);dism=disbe(dismat
4、);core=cor(dism);[red,row]=redu(dism);time=toc%dismatrix.m%生成未经处理的区分矩阵dismatfunctiondismat=dismatrix(a,d,pos)[m,n]=size(a);p=1;index1=0;index2=0;index=0;dis=-1*ones(m*(m-1)/2,n);fori=1:m forj=i+1:m if(isxbelongtopos(i,pos)&~isxbelongtopos(j,pos))...
5、
6、(~isxbelongtopos(i,pos)&isxbelongtopos(j,pos))...
7、(isxbelongtopos(i,pos)&isxbelongtopos(j,pos)&~isxybelongtoindD(i,j,d)) index2=1; end ifindex2==0 continue; end fork=1:n ifa(i,k)
8、~=a(j,k) dis(p,k)=1; index1=1; elsedis(p,k)=0; end end ifindex1==1 p=p+1;index=1; end index1=0; index2=0; endendifp<=m*(m-1)/2 ifindex==0 dismat=[]; return
9、; end ifdis(p,1)==-1 p=p-1; endelsep=m*(m-1)/2;enddismat=dis(1:p,:);%redu.m%对已经处理过的区分矩阵进行知识约简function[red,row]=redu(dism)[m,n]=size(dism);red=[];row=0;ifm<=0 return;endfori=1:n ifdism(1,i)~=0 row=row+1; endendred(1:row,:)=zeros(row,n);j
10、=1;fori=1:row whiledism(1,j)==0 j=j+1; end red(i,j)=1; j=j+1;endtemp=[];tempdis=[];rowd=0;rowd1=0;fori=2:m j=1; whilej<=row temp=uni(dism(i,:),red(j,:));