-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdemo_transfer_pooling.m
More file actions
77 lines (69 loc) · 3.18 KB
/
demo_transfer_pooling.m
File metadata and controls
77 lines (69 loc) · 3.18 KB
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
clear all;
close all;
clc;
rng('shuffle')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This compares marginal predictor method [1] with pooling method.
% It uses kernel approximation and then liblinear as a solver for speed up
% input - train and test datasets = datasets in cell format.
% - datasets{i}.testx contains all features and Dataset{i}.testy
% contains all labels. Don't get mislead by testx name. It contains
% all datapoints.
% - numberOfTrainingUser = number of datasets that are used for training
% In datasets First numberOfTrainingUser are considered as training
% datasets
% - numberOfExamplesPerTask
% - rand_perm_test - datasets to be used as test datasets
% - task_type - it could be 'regression' or 'binary'
% - cross_val - 1 if you want to do cross val otherwise 0
% - L,Q,D - number of random fourier features to approximate kernel
% output - res_avg_test = test error using marginal predictors method
% - res_avg_train = train error using marginal predictors method
% - res_avg_test_pooled = test error using pooling method
% - res_avg_train_pooled = train error using pooling method
% - In case of regression - squared error
% - In case of binary classification - % 0-1 error
% Warning - THIS METHOD DOES FIVE FOLD CROSS VALIDATION.
% SO numberOfTrainingUser SHOULD BE ONLY MULTIPLE OF 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% load the training data based on the input
current_path = pwd;
%Please download liblinear and run make file before running these
%experiments
liblinear_path = strcat(current_path,'\liblinear-1.95');
addpath(genpath(liblinear_path))
load Copy_of_synth_data % synth_parkinson_regression_data
task_type = 'binary'; % It could be either 'binary' or 'regression'
numberOfTrainingUser = 20; %5,10,15,20,25,30,35, should be multuple of 5 and first (1:numberOfTrainingUser) will be selected as training datasets
useAllExamples = 0;
numberOfExamplesPerTask = 32;
L = 100;
Q = 100;
D = 100;
numb_iter = 1;
rand_perm_test = 21:30; % test datasets
cross_val = 1; % 1 if you want to do cross validation, 0 if you don't want to
% If you don't want to do cross validation then input all parameters here.
if cross_val == 0
bw1_est = 100;
bw2_est = 100;
bw3_est = 100;
c_est = 1;
bw1_est_pooling = 100;
c_est_pooling = 1;
elseif cross_val == 1
bw1_est = 100;
bw2_est = 100;
bw3_est = 100;
c_est = 1;
bw1_est_pooling = 100;
c_est_pooling = 1;
end
[res_avg_test,res_avg_train,res_avg_test_pooled,res_avg_train_pooled] = cross_validation_pooling_transfer(useAllExamples,numberOfExamplesPerTask,numberOfTrainingUser,datasets,L,Q,D,cross_val,rand_perm_test,numb_iter,task_type,bw1_est,bw2_est,bw3_est,c_est,bw1_est_pooling,c_est_pooling);
% if strcmp(task_type,'binary')
% res_avg_test = 100 - res_avg_test;
% res_avg_train = 100 - res_avg_train;
% res_avg_test_pooled = 100- res_avg_test_pooled;
% res_avg_train_pooled = 100- res_avg_train_pooled;
% end
save('Copy_of_synth_data_results','res_avg_test','res_avg_train','res_avg_test_pooled','res_avg_train_pooled')