


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、粗糙集屬性約簡題目:SARS診斷注:這是我學(xué)粗糙集時(shí)老師給的作業(yè)U干 咳呼 吸 困 難血 液 檢 測高 燒38度X射線濃痰血 細(xì) 胞 多寒 戰(zhàn)肌 肉 酸 痛乏力胸膜痛頭 痛非典11111000011011200000000000003101000000100040001111010110510011111011006010111 1111001071000111001110811110000110119101110001101110111100 100 11 11 101 !_111I-11011100011011121 10d110 00110 11屬性約簡的順序如下:求正域、生成未經(jīng)處理的
2、區(qū)分矩陣、對區(qū)分矩陣進(jìn)行化簡、求核、對已經(jīng)處理過的區(qū)分矩陣進(jìn)行屬性約簡。約簡后的決策表有26行,所有12個(gè)屬性都是正域中的屬性,核為空程序:% mai n.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,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,
3、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);core=cor(dism);red,row=redu(dism);time=toc% dismatrix.m% 生成未經(jīng)處理的區(qū)分矩陣 dismatfunction dismat=dismatrix(a,d,pos)m,n=size(a);p=1;index1=0;index
4、2=0;index=0;dis=-1*ones(m*(m-1)/ 2,n);for i=1:mfor j=i+1:mif (isxbelongtopos(i,pos)&isxbelongtopos(j,pos).|(isxbelongtopos(i,pos)&isxbelongtopos(j,pos).|(isxbelongtopos(i,pos)&isxbelongtopos(j,pos)&isxybelongtoindD(i,j,d) index2=1;endif index2=0continue;endfor k=1:nif a(i,k)=a(j,k)dis(p,k)=1;index1=
5、1;else dis(p,k)=0;endendif index1=1p=p+1;index=1;endindex1=0;index2=0;endendif p=m*(m-1)/ 2if index=0dismat=;return;endif dis(p,1)=-1p=p-1;endelse p=m*(m-1)/ 2;enddismat=dis(1:p,:);% redu.m% 對已經(jīng)處理過的區(qū)分矩陣進(jìn)行知識約簡 function red,row=redu(dism) m,n=size(dism);red=; row=0; if m=0return;endfor i=1:nif dism(1,
6、i)=0 row=row+1;end end red(1:row,:)=zeros(row,n); j=1; for i=1:rowwhile dism(1,j)=0 j=j+1;endred(i,j)=1;j=j+1; end temp=;tempdis=; rowd=0;rowd1=0; for i=2:mj=1;while j=row temp=uni(dism(i,:),red(j,:); s,n=size(temp);rowd1=rowd+s; tempdis(rowd+1:rowd1,:)=temp; rowd=rowd1;j=j+1; temp=;endred=; red=dis
7、be(tempdis); tempdis=;row,n=size(red); rowd=0;rowd1=0;% disbe.m% 對區(qū)分矩陣或者約簡矩陣進(jìn)行化簡即去掉包含關(guān)系 function dism=disbe(dis)m,n=size(dis);p=m;for i=1:mif dis(i,1)=-1for j=1:mif i=j & dis(j,1)=-1if dis(i,:)=dis(j,:) dis(i,:)=dis(j,:); dis(j,1)=-1; p=p-1;endendendendenddism=ones(p,n);j=1;for i=1:pwhile j=m & dis(
8、j,1)=-1j=j+1;enddism(i,:)=dis(j,:);j=j+1;end% posCD.m% a 為條件屬性矩陣, d 為決策屬性向量% pos 為正域 , 保存條件屬性矩陣的索引值 function pos=posCD(a,d)m,n=size(a);p=m;index=0;for i=1:mif a(i,1)=-1for j=i+1:mif a(j,1)=-1 &(a(i,:)=a(j,:)&d(i)=d(j) a(j,1)=-1;p=p-1;index=1;endif index=1 a(i,1)=-1;p=p-1;index=0; end end end pos=zer
9、os(p,1);i=1;for r=1:pwhile a(i,1)=-1&i=mi=i+1;endpos(r)=i;r=r+1;i=i+1;end% cor.m% 對已經(jīng)處理過的區(qū)分矩陣求核 function core=cor(dism) m,n=size(dism); core1=zeros(1,n);number=0;for i=1:mnum=0;p=0;for j=1:nif dism(i,j)=0 num=num+1; p=j;endendif num=1core1(p)=1; number=number+1;endendif number=0core=0;elsecore=zeros
10、(1,number);j=1;for i=1:numberwhile core1(j)=0 j=j+1;end core(i)=core1(j); j=j+1;endend% uni.m%對區(qū)分矩陣的第i行和red(j,:)運(yùn)算,即將a中 %所有的1分別插入到red(j,:)中,待去掉包含關(guān)系 function tempred=uni(disa,red) m,n=size(red);num=0;for i=1:nif disa(i)=0 num=num+1;endendtempred=ones(m*num,n);temp=;j=1;for i=1:numwhile disa(j)=0 j=j+
11、1;endtemp=red;temp(:,j)=ones(m,1); tempred(i-1)*m+1:i*m,:)=temp;j=j+1;end% isxbelongtopos.m% 判斷 x 是否在正域 pos 中% x 為索引值% 返回值 p ,如果 x 在 pos 中 p=1 否則 p=0 function p=isxbelongtopos(x,pos) m,n=size(pos);p=0;if x=0p=-1;return;endfor i=1:mif x=pos(i)p=1;break;endend% isxybel on gtoi ndD.m%判斷x,y是否在indD中% x,y
12、為索引值% 返回值p,如果x,y在indD中p=1否則p=0 function p=isxybel on gto in dD(x,y,d)if xsize(d) | ysize(d)P=-1;return;endif d(x)=d(y)p=1;else p=0;end約簡后的決策表序號干咚呼吸困礙血液檢測高燒戒2X射躋濃痰白跚胞埶In肉醴旖乏劉頭痛10O1- Oo1 ooo1 o.li o0.2O1L111O1Ao10.ooooo3OOOI LO-.1 oooooo41 O110.1O1Ag I m0.ooooo5OO0. -O0.-Ao0.o.% o0.6O11OO1-oe n-oo.T oo-7 4OO. 二O0.10.1o 一o.T o0.8OOO11 IXO1 ooT-1n*1AIT o911門-.1 Mo10.A-n-0.t10.WOOOli1oT a,T o0.o1-o 0.o.t11TAD2-1QOOOo-0o1-1* a1*0.31-OOOOoo0.*I*o1*14 *1-OOO- -0.0.o代一 -.110.5.111O門O1 OooooT111 - oo6IX -OOOo0.0.o
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 明確職業(yè)目標(biāo)的成長路徑計(jì)劃
- 生活與事業(yè)雙豐收的秘籍計(jì)劃
- 2025年發(fā)動(dòng)機(jī)基本件:飛輪項(xiàng)目發(fā)展計(jì)劃
- 2025年血液凈化產(chǎn)品項(xiàng)目建議書
- 2025年工藝品及其他制造產(chǎn)品項(xiàng)目發(fā)展計(jì)劃
- 2025年包裝材料加工機(jī)械項(xiàng)目建議書
- 2025年運(yùn)動(dòng)捕捉軟件合作協(xié)議書
- 2025年包裝印刷機(jī)械項(xiàng)目合作計(jì)劃書
- 2025年工業(yè)清洗清理設(shè)備:工業(yè)吸塵設(shè)備項(xiàng)目發(fā)展計(jì)劃
- 跨區(qū)域業(yè)務(wù)數(shù)據(jù)轉(zhuǎn)換協(xié)調(diào)機(jī)制
- 初二上冊好的數(shù)學(xué)試卷
- 廣東省潮州市2024-2025學(xué)年九年級上學(xué)期期末道德與法治試卷(含答案)
- 2025年職業(yè)衛(wèi)生工作計(jì)劃
- 突發(fā)公共衛(wèi)生事件衛(wèi)生應(yīng)急
- 做賬實(shí)操-農(nóng)貿(mào)市場的賬務(wù)處理示例
- 余華《活著》解讀課件
- 部編版2024-2025學(xué)年三年級上冊語文期末測試卷(含答案)
- 護(hù)理帶教老師述職報(bào)告
- 《中國居民膳食指南》課件
- 門窗安裝施工安全管理方案
- 婦科手術(shù)麻醉
評論
0/150
提交評論