forked from huang1225s/GEDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEasyTL2.m
26 lines (23 loc) · 816 Bytes
/
EasyTL2.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
function [acc,y_pred] = EasyTL2(Xs,Ys,Xt,Yt,~)
% Inputs:
%%% Xs : source data, ns * m
%%% Ys : source label, ns * 1
%%% Xt : target data, nt * m
%%% Yt : target label, nt * 1
%%%%%% The following inputs are not necessary
%%% intra_align : intra-domain alignment: coral(default)|gfk|pca|raw
%%% dist : distance: Euclidean(default)|ma(Mahalanobis)|cosine|rbf
%%% lp : linear(default)|binary
C = length(unique(Ys)); % num of shared class
if C > max(Ys)
Ys = Ys + 1;
Yt = Yt + 1;
end
m = length(Yt);
lp = 'linear';
dist = 'euclidean';
[~,Dct]= get_class_center(Xs,Ys,Xt,dist);
fprintf('Start intra-domain programming...\n');
[Mcj] = label_prop(C,m,Dct,lp);
[~,y_pred] = max(Mcj,[],2);
acc = mean(y_pred == Yt);