?? clsf_dpd_fast2.m
字號:
function [dependency,smp_csst]=clsf_dpd_fast2(data_array,delta,smp_chk)
%程序描述:clsf_dpd_fast2,計算新加入的一個屬性的依賴度,相比1,減少了鄰域計算次數(shù),但增加了前面的判斷次數(shù)
%(no,no,no))-----------新思想+我的改進1+我的改進2
%5種情況:(每次是否檢查全部樣本、鄰域樣本是否全部檢查、距離是否計算完)=>(yes,yes,yes)+(no,yes,yes)+(no,yes,n
%o)+(no,no,yes)+(no,no,no)
%data_array:標準化之后的數(shù)據(jù),數(shù)組,列表示一個屬性(包括決策屬性)在不同樣本上的取值,行表示一個樣本在不同屬性上的取值
%delta:鄰域大小,固定值
%smp_chk:需判斷類別的樣本編號,新加入的屬性只對這些樣本有作用,因此計算的是新加入屬性的依賴度
[m,n]=size(data_array);
num_rightclassified=0;
smp_csst=[];
for i=1:length(smp_chk)
% find the neighborhood of xi
sign=1;
j=0;
while j~=m
j=j+1;
sqare_distance=0;
in=1;
if j~=i
k=0;
while k<n-1
k=k+1;
d=(data_array(smp_chk(i),k)-data_array(j,k))^2;
if d>1
sqare_distance=sqare_distance+1; % for categorical features
else
sqare_distance=sqare_distance+d; % for numerical features
end
if sqare_distance>delta^2
in=0; % in is a flag which shows whether the current sample is in the neighborhood of xi or not
k=n-1;
end
end
if in==1
if data_array(j,n)~=data_array(smp_chk(i),n)
j=m;
sign=0;
end
end
end
end
if sign==1
num_rightclassified=num_rightclassified+1;
smp_csst=[smp_csst,smp_chk(i)];
end
end
dependency=num_rightclassified/m;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -