-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForwardSelection.m
More file actions
37 lines (33 loc) · 932 Bytes
/
Copy pathForwardSelection.m
File metadata and controls
37 lines (33 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [ best ] = ForwardSelection( LOO_Data,LOO_class,step ,isLoo )
Data=LOO_Data;
Data(:,step) = [];
[s featureSize]=size(Data);
receiveData =LOO_Data(:,step);
minErr=1;
choosenIndex=-1;
for i=1:featureSize
nextData=Data(:,i);
featureIndex=nextData(1);
if(isempty(receiveData)==0)
LOO_DataIndex=horzcat(receiveData,Data(:,i));
else
LOO_DataIndex=Data(:,i);
end
LOO_DataIndex(1,:)=[];
if (isLoo==1)
CVerr = LOOCross(LOO_DataIndex,LOO_class);
else
CVerr = MOOCrossSpambase(LOO_DataIndex,LOO_class);
end
if(CVerr<minErr)
minErr=CVerr;
choosenIndex=featureIndex;
end
end
if (isLoo==1)
% disp(sprintf('LOO Err:%1.3f feature:%d',minErr,choosenIndex));
else
% disp(sprintf('MOO Err:%1.3f feature:%d',minErr,choosenIndex));
end
best=choosenIndex;
end