-
Notifications
You must be signed in to change notification settings - Fork 60
/
ftTrans_pca.m
44 lines (39 loc) · 1.4 KB
/
ftTrans_pca.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
function [ftAllNew,transMdl] = ftTrans_pca(ftAll,maSrc,target,maLabeled,param)
%A baseline to other domain adaptation methods, use PCA or KPCA to extract
% features.
%
% Application scope:
% + Any scenario since no domain adaptation is done.
%
% ftAll: All samples in all domains. n-by-m matrix, n is the number of
% samples, m is the dimension of features.
% maSrc,target,maLabeled: useless.
%
% param: Struct of hyper-parameters, please see the first cell of this
% program ("default parameters") for details. You can set parameter p to
% x by setting param.p = x. For parameters that are not set, default
% values will be used.
%
% ftAllNew: All samples in the learned subspace.
% transMdl: A struct containing the model, transMdl.W is the projection
% matrix.
%
% The ftProc_(k)pca_tr function is a part of the PRTools toolbox.
% if kerName is set in param, use KPCA; else, use original linear PCA.
%
% Copyright 2016 Ke YAN, Tsinghua Univ. http://yanke23.com , [email protected]
%% default parameters
pcaCoef = 0; % see ftProc_pca_tr
kerName = 'poly'; % see ftProc_kpca_tr
kerSigma = 1;
degree = 2;
defParam
%% compute and project the samples
if ~isfield(param,'kerName')
[ftAllNew,pcaModel] = ftProc_pca_tr(ftAll,[],struct('pcaCoef',pcaCoef));
else
[ftAllNew,pcaModel] = ftProc_kpca_tr(ftAll,[],struct('pcaCoef',pcaCoef,...
'kernel',kerName,'kerSigma',kerSigma,'degree',degree));
end
transMdl = pcaModel;
end