-
Notifications
You must be signed in to change notification settings - Fork 2
/
realLab_JFM89_BS_Unmix.m
202 lines (138 loc) · 4.92 KB
/
realLab_JFM89_BS_Unmix.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
%
%
% Author: Tales Imbiriba
% Last Modified in November 2016
clear all;
close all;
% loading data!
%load jfm89_oliv_enst_mix.mat
%load jfm89_oliv_mag_mix.mat
%load jfm89_oliv_arn_mix.mat
% load jfm89_arn_ens_mix.mat
load jfm89_oliv_arn_ens_mix.mat
[L,R] = size(M);
% FCLS
[~, a_fcls] = estimateLinearModel(y, M, true);
% GKKM
kbwkkm = 0.1006;
lambda = 2;
tic
% band selection
%[kkmBS] = kernelKMeansBandSelection(M, Nb_kkm, kbw);
[kkmBS] = kernelKMeansBandSelectionAIC(M,kbwkkm,lambda);
yr=y(kkmBS,:);
Mr=M(kkmBS,:);
% unmix!
%[a_kkm,~,r_kkm] = tskHype(yr, Mr,[],[],kbwkkm);
[a_kkm,~,r_kkm] = tskHype_reducedData(yr, Mr,[],[],kbwkkm,[],M,kkmBS);
% time to BS + Unmix
kkmTime = toc;
%computing dictionary mu
Kg = computeKernelMatrix(Mr,kbwkkm);
mu_kkm = max(max(Kg-eye(size(Kg))));
%[rmse_kkm, std_kkm] = RMSEAndSTDForMatrix(r_kkm,y);
%[rmse, stdd] = RMSEAndSTDForMatrix(a_kkm, a_mix);
[rmse, stdd] = RMSEAndSTDForMatrix(r_kkm, y);
fprintf('GKKM & %.4f $\\pm$ %.4f & %d & %d & %.4f\\\\ \n', rmse, stdd, kkmTime, length(kkmBS), mu_kkm);
% Fullband SK-Hype
kbw_skp = 0.00885444926741354;
tic
[a_skp,~,r_skp] = tskHype(y, M,[],[],kbw_skp);
skpTime = toc;
disp('Results with Image reconstruction error')
fprintf('Strategy & RMSE $\\pm$ STD & Time & $N_b$ & $\\mu$\\\\ \\hline\n');
%[rmse_skp, std_skp] = RMSEAndSTDForMatrix(a_skp,a_mix);
[rmse_skp, std_skp] = RMSEAndSTDForMatrix(r_skp,y);
fprintf('SK-Hype & %2.4f $\\pm$ %2.4f & %2.4f & %d & -\\\\ \\hline\n', rmse_skp, std_skp, skpTime,L);
ms=[5 10 20 30];
%ms = [30];
% find Gaussian kernel bandwidth!
K_s1 = computeKernelMatrix(M,1);
c=0;
count =1;
for i=1:L-1
for j=i+1:L
c(count) = K_s1(i,j);
count = count + 1;
end
end
cliqueCBSTime = zeros(size(ms));
greedyCBSTime = zeros(size(ms));
mu_clique = zeros(size(ms));
mu_greedy = zeros(size(ms));
Nb_clique = zeros(size(ms));
Nb_greedy = zeros(size(ms));
i = 1;
%Opt_opt = optimset('Algorithm','interior-point','TolFun',1e-10);
Opt_opt = optimset('Algorithm','interior-point');
for m=ms
% m=10; % number of desired bands
mu_0 = 1/(m-1);
[kbw,fval] = fmincon(@(kbw)(abs(mean(c.^(1/(kbw^2)))-mu_0)),1,[],[],[],[],1e-10,1e100,[],Opt_opt);
KM = computeKernelMatrix(M,kbw);
% clique (CCBS)
tic
% band selection
[cliqueCBS] = clique_coherence_bandselection( KM, mu_0, [], 1 );
yr=y(cliqueCBS,:);
Mr=M(cliqueCBS,:);
% unmix!
%[a_clique,~,r_clique] = tskHype(yr, Mr,[],[],kbw);
[a_clique,~,r_clique] = tskHype_reducedData(yr, Mr,[],[],kbw,[],M,cliqueCBS);
% time to BS + Unmix
cliqueCBSTime(i) = toc;
Nb_clique = length(cliqueCBS);
Nb_kkm = Nb_clique;
%computing dictionary mu
Kg = computeKernelMatrix(Mr,kbw);
mu_clique(i) = max(max(Kg-eye(size(Kg))));
%[rmse_clique, std_clique] = RMSEAndSTDForMatrix(r_clique,y);
% greedy (GCBS)
tic
% band selection
[greedyCBS] = buildDictionaryUsingCoherenceFactorKM(KM, mu_0);
yr=y(greedyCBS,:);
Mr=M(greedyCBS,:);
% unmix!
%[a_greedy,~,r_greedy] = tskHype(yr, Mr,[],[],kbw);
[a_greedy,~,r_greedy] = tskHype_reducedData(yr, Mr,[],[],kbw,[],M,greedyCBS);
% time to BS + Unmix
greedyCBSTime(i) = toc;
Nb_greedy = length(greedyCBS);
%computing dictionary mu
Kg = computeKernelMatrix(Mr,kbw);
mu_greedy(i) = max(max(Kg-eye(size(Kg))));
%[rmse_greedy, std_greedy] = RMSEAndSTDForMatrix(r_greedy,y);
fprintf('$M = %d$, $\\mu_0 = %.4f$, $\\sigma = %.4f$\\\\ \\hline\n', m, mu_0, kbw);
% printf('CCBS & %.4f $\\pm$ %.4f & %.2f & %d %.4f\n', rmse_clique, std_clique, Nb_clique, mu_clique);
% printf('GCBS & %.4f $\\pm$ %.4f & %.2f & %d %.4f\n', rmse_greedy, std_greedy, Nb_greedy, mu_greedy);
% printf('GKKM & %.4f $\\pm$ %.4f & %.2f & %d %.4f\n', rmse_kkm, std_kkm, Nb_kkm, mu_kkm);
%[rmse, stdd] = RMSEAndSTDForMatrix(a_clique, a_mix);
[rmse, stdd] = RMSEAndSTDForMatrix(r_clique, y);
fprintf('CCBS & %.4f $\\pm$ %.4f & %.4f & %d & %.4f\\\\ \n', rmse, stdd, cliqueCBSTime(i), Nb_clique, mu_clique(i));
%[rmse, stdd] = RMSEAndSTDForMatrix(a_greedy, a_mix);
[rmse, stdd] = RMSEAndSTDForMatrix(r_greedy, y);
fprintf('GCBS & %.4f $\\pm$ %.4f & %.4f & %d & %.4f\\\\ \n', rmse, stdd, greedyCBSTime(i),Nb_greedy, mu_greedy(i));
i = i + 1;
% figure
% subplot(3,1,1)
% plot(wlength, abs(mean(y'-r_skp')))
% xlim([0.3 2.6])
% ylim([0 0.03])
% set(gca,'FontSize',14)
% legend('SK-Hype','location', 'NorthEast')
%
% subplot(3,1,2)
% plot(wlength, abs(mean(y'-r_kkm')))
% xlim([0.3 2.6])
% ylim([0 0.03])
% set(gca,'FontSize',14)
% legend('GKKM','location', 'NorthEast')
%
% subplot(3,1,3)
% plot(wlength, abs(mean(y'-r_clique')))
% xlim([0.3 2.6])
% ylim([0 0.03])
% set(gca,'FontSize',14)
% legend('CCBS','location', 'NorthEast')
end