在 Arthur B. 的帮助下,我终于理解了这个概念。这是我的实现。尽管我使用了 Plus l Take away r 算法(Sequential Forwards Backward Search),但我会发布它,因为一旦删除了 Backward Search,它基本上是相同的。下面的实现是在 matlab 中,但很容易理解:
S=zeros(Size,1); %Initial the binary array feature list with all zeros implying no feature selected
k=0;
while k<n %Begin SFS. n is the number of features that need to be extracted
t=k+l; %l is the number of features to be added in each iteration
while k<t
R=zeros(Size,1); %Size is the total number of features
for i=1:Size
if S(i)==0 %If the feature has not been selected. S is a binary array which puts a one against each feature that is selected
S_copy=S;
S_copy(i)=1;
R=OperateBhattacharrya(Matrices,S_copy,i,e,R); %The result of each iteration is stored in R
end
end
k=k+1; %increment k
[~,N]=max(R); %take the index of the maximum element in R as the best feature to be selected
S(N)=1; % put the index of selected feature as 1
end
t=k-r; %r is the number of features to be removed after selecting l features. l>r
while k>t %start Sequential Backward Search
R=zeros(Size,1);
for i=1:Size
if S(i)==1
S_copy=S;
S_copy(i)=0;
R=OperateBhattacharrya(Matrices,S_copy,i,1,R);
end
end
k=k-1;
[~,N]=max(R);
S(N)=0;
end
fprintf('Iteration :%d--%d\n',k,t);
end
我希望这可以帮助任何有类似问题的人。