-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmt_SCML.m
57 lines (48 loc) · 1.72 KB
/
mt_SCML.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
% Copyright 2014 Yuan Shi & Aurelien Bellet
%
% This file is part of SCML.
%
% SCML is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% SCML is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with SCML. If not, see <http://www.gnu.org/licenses/>.
function [L_set,W,B] = mt_SCML(xTr, yTr, numBasis, beta)
% mt-SCML
% xTr: a cell array, the ith cell contains the data matrix
% (each row is a point) for ith task
% yTr: a cell array, the ith cell contains the label vector for the ith
% task
% numBasis: total number of basis elements for all tasks
% beta: regularization parameter
%
% L_set: a cell array, the ith cell contains the transformation for each task
% W: the ith row contains the weight for ith task
% B: basis set
%
% Last Modified: 4/15/2014
n_task = length( xTr );
% generate triplets
for t = 1:n_task
[T_cell{t}, SS_cell{t}]= generate_knntriplets(xTr{t}, yTr{t}, 3, 10);
end
% generate bases
B = [];
for t = 1:n_task
B_part = generate_bases_LDA(xTr{t}, yTr{t}, numBasis/n_task);
B = [B; B_part];
end
% initializing W
W = ones(n_task, numBasis);
%% learning W
W = learning_W_mt_rda_2_1(W, B, xTr, T_cell, beta);
for t = 1:n_task
L_set{t} = get_transformation_w(B, W(t,:));
end