function [recall, precision, obs1,classifier, time]=DWLSTWSVM(C,test_data,C1,mu,K)
[no_input,no_col]=size(C);
obs = C(:,no_col);
A = [];
B = [];
for i = 1:no_input
if(obs(i) == 1)
A = [A;C(i,1:no_col-1)];
else
B = [B;C(i,1:no_col-1)];
end
end
[m1,n] = size(A);
e1 = ones(m1,1); %one's vector
[m2,n] = size(B);
e2 = ones(m2,1); %one's vector
m= m1 + m2;
C = [A ; B];
%%%Density weights assignment%%%%%%%%%%%
D1=diag(weight(A,K));
D2=diag(weight(B,K));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
C2=C1;
ep = 0.00001;
tic %%%%%%time calculation starts here
K=zeros(m1,m);
%%%%%%%%%Gaussian kernel%%%%%%%%%%%
for i=1:m1
for j=1:m
nom = norm( A(i,:) - C(j,:) );
K(i,j) = exp( -1/(2*mu*mu) * nom * nom );
end
end
G
加权的模糊最小二乘支持向量机代码
最新推荐文章于 2023-04-19 14:52:39 发布