📄 sfs.m
字号:
function [nrsfs,fsfs] = sfs(data,cla,nameopt)
% SFS performs the SFS algorithm for training data
%
% [nrsfs fs] = sfs(data,cla)
%
% The function runs SFS on training data data,and training class cla.
%
% data = input of matrix (feature x examples)
% cla = vector (1 x examples)
%
% nrsfs = number of right recognition
% fsfs = vector (select index of feature)
% Author : MingXian Li
% Date : 21.11.2007
if size(data,1)==1
[nr mu_v] = eac(data,cla)
nrsfs = nr;
fsfs = 1;
return
end
%feature vector Initialization fv = [0 0 ...0]
fv(1,1:size(data,1)) = 0;
k = 1;
%if select feature i ,dann set fv(i)=1
while sum(fv)<size(data,1)
j = 1;
for i=1:size(data,1)
sv = fv;
sv(i) =1;
if (~isequal(sv,fv))
id = find(sv==1);
% func = str2func(nameopt);
[nr mu_v] = feval(nameopt,data(id,:),cla);
nreac{j} = nr;
fvtmp{j} = sv;
j = j+1;
end
end
%Afterwards each loop,Compared with Combination, find the best Combination fv.
[nr1 index1] = max(cell2mat(nreac));
fv = cell2mat(fvtmp(index1));
fvmax{k} = fv;
nrmax{k} = nr1;
k = k+1;
nreac = [];
fvtmp = [];
end
%Compared with all best Combination, find the best Combination of feature fvmax{index2}.
[nr2 index2] = max(cell2mat(nrmax));
nrsfs = nr2;
fsfs = find(cell2mat(fvmax(index2))==1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -