-
Notifications
You must be signed in to change notification settings - Fork 13
/
demo_classify_pie.m
43 lines (35 loc) · 1.29 KB
/
demo_classify_pie.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
% Joint Probability Distribution Adaptation (JPDA)
% Author: Wen Zhang
% Date: Dec. 8, 2019
% E-mail: [email protected]
clc; clear all;
srcStr = {'PIE05','PIE05','PIE05','PIE05','PIE07','PIE07','PIE07','PIE07','PIE09','PIE09','PIE09','PIE09','PIE27','PIE27','PIE27','PIE27','PIE29','PIE29','PIE29','PIE29'};
tgtStr = {'PIE07','PIE09','PIE27','PIE29','PIE05','PIE09','PIE27','PIE29','PIE05','PIE07','PIE27','PIE29','PIE05','PIE07','PIE09','PIE29','PIE05','PIE07','PIE09','PIE27'};
T = 10;
for i = 1:20
src = char(srcStr{i});
tgt = char(tgtStr{i});
fprintf('%d: %s_vs_%s\n',i,src,tgt);
% Preprocess data using L2-norm
load(strcat('./data/',src));
Xs = fea'; Xs = Xs*diag(sparse(1./sqrt(sum(Xs.^2))));
Ys = gnd;
load(strcat('./data/',tgt));
Xt = fea'; Xt = Xt*diag(sparse(1./sqrt(sum(Xt.^2))));
Yt = gnd;
% JPDA evaluation
options.p = 100;
options.lambda = 0.1;
options.ker = 'primal';
options.mu = 0.1;
options.gamma = 1.0;
Cls = []; Acc = [];
for t = 1:T
[Zs,Zt] = JPDA(Xs,Xt,Ys,Cls,options);
mdl = fitcknn(Zs',Ys);
Cls = predict(mdl,Zt');
acc = length(find(Cls==Yt))/length(Yt);
Acc = [Acc;acc];
end
fprintf('JPDA=%0.4f\n\n',Acc(end));
end