-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.m
46 lines (35 loc) · 880 Bytes
/
test.m
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
38
39
40
41
42
43
44
45
46
clc;
clear;
close all;
addpath(genpath(cd));
dataNames = {'SRBCT'};
k = 10;
for dataName = dataNames
disp(dataName);
load(dataName{1});
data = full(data);
% normalize
data = (data - min(data, [], 1)) ./ (max(data, [], 1) - min(data, [], 1));
data(isnan(data)) = 0;
[m, featNum] = size(data);
% crossvalid
indices = crossvalind('Kfold', m, k);
for i = 1 : 30
disp(['K Fold ', int2str(i)]);
% crossvalid
testIdx = indices == i;
trainIdx = ~testIdx;
testData = data(testIdx, :);
testLabel = label(testIdx, :);
trainData = data(trainIdx, :);
trainLabel = label(trainIdx, :);
tic;
t1 = clock;
[x, errTr, selFeatNum] = VGEA(trainData, trainLabel, dataName{1}, i);
t2 = clock;
toc;
time = etime(t2, t1);
accTr = 1 - errTr;
save(strcat('result-', dataName{1}, '-', num2str(i)), 'x', 'errTr', 'selFeatNum', 'accTr', 'time');
end
end