-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSampleCode.m
More file actions
66 lines (47 loc) · 1.42 KB
/
SampleCode.m
File metadata and controls
66 lines (47 loc) · 1.42 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%% Sample Code
%% Normalisation
data_norm = bsxfun(@rdivide, data, sqrt(sum(data.^2,2)));
%% LPBoost;
data_dup = [data_norm, -data_norm]
[M, ~] = size(data_dup);
nu = 0.1:0.1:0.9;
group = zeros(M, length(nu));
acc = zeros(length(nu), 1);
for i = 1 : M
data_new = data_dup;
data_new(i, :) = [];
label_new = label;
label_new(i) = [];
for j = 1 : length(nu)
model = LPBoostYS(data_new,label_new,1/(nu(j)*(M-1)),16000);
group(i, j) = sign(data_dup(i, model.idx) * model.a');
end;
end;
for i = 1 : length(nu)
acc(i) = sum(group(:, i) == label)/M;
end;
%% Dynamic LPBoost (Fixed Length)
% Set length
l = 5;
M = size(data_norm, 1);
miu = 0.1:0.1:0.9;
group = zeros(M, length(miu));
acc = zeros(length(miu), 1);
for i = 1 : length(miu)
for j = 1 : M
label_new = label;
label_new(j) = [];
data_new = data_norm;
data_new(j, :) = [];
model = dynamicLPBoostUnnorm(data_new,label_new,1/((M-1)*miu(i)),l,16000);
data_new = zeros(1, size(model.sub, 2));
for counter = 1 : size(model.sub, 2)
data_new(counter) = featSelectUnnorm(data_norm(j, :), model.sub(:, counter),...
model.atr{counter}, length(model.sub(:, counter)));
end;
group(j, i) = sign(data_new * model.a');
end;
end;
for i = 1 : length(miu)
acc(i) = sum(group(:, i) == label)/M;
end;