-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathRunOneNNWITHDMStarLightCurves.m
220 lines (190 loc) · 14.1 KB
/
RunOneNNWITHDMStarLightCurves.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
function RunOneNNWITHDMStarLightCurves(DataSetStartIndex, DataSetEndIndex, DistanceIndex)
Methods = [cellstr('ED'), 'SBD', 'MSM', 'DTW', 'EDR', 'SINK', 'GAK', 'LCSS', 'TWE', 'DISSIM', 'TQuEST', 'Swale', 'KDTW', 'ERP', 'Lorentzian'];
Datasets = [cellstr('StarLightCurves'), 'FordA', 'FordB', 'ElectricDevices'];
% Sort Datasets
[Datasets, DSOrder] = sort(Datasets);
%LeaveOneOutAccuracies = zeros(length(Datasets),20);
%LeaveOneOutRuntimes = zeros(length(Datasets),20);
%Results = zeros(length(Datasets),4);
for i = 1:length(Datasets)
if (i>=DataSetStartIndex && i<=DataSetEndIndex)
Results = zeros(1,67);
disp(['Dataset being processed: ', char(Datasets(i))]);
DS = LoadUCRdataset(char(Datasets(i)));
% Parameters based on DistanceIndex choice
[Params, Params2]= DistanceToParameter(DistanceIndex);
% RBF from ED
%Params = [2^-20,2^-19,2^-18,2^-17,2^-16,2^-15,2^-14,2^-13,2^-12,2^-11,2^-10,2^-9,2^-8,2^-7,2^-6,2^-5,2^-4,2^-3,2^-2,2^-1,2^0,2^1];
%Params = [2^1];
k=1;
for w=50:50:DS.TrainInstancesCount
disp(k);
[~,DMTESTTOTRAIN] = DistanceToDM(DistanceIndex,Datasets,i,Methods, Params(1), Params2(1));
%DMTESTTOTRAIN = DM2KM(DMTESTTOTRAIN, 2);
Results(i,k) = 1 - OneNNClassifierWITHDMCBFBIG(DS, DMTESTTOTRAIN, w);
k=k+1;
end
dlmwrite( strcat('./RunOneNNWITHDMStarLightCurves/', 'RESULTS_RunOneNNWITHDMStarLightCurves_', char(Datasets(i)) ,'_',char(Methods(DistanceIndex))), Results, 'delimiter', ',');
end
end
end
function [DMTRAIN,DMTESTTOTRAIN] = DistanceToDM(DistanceIndex,Datasets,i,Methods, Param1, Param2)
DMTRAIN = [];
if DistanceIndex==1
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==2
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==3
% MSM - 10 Parameters
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==4
% DTW - 0-20, 100 - 22 Parameters
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==5
% EDR - 20 Parameters
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==6
% SINK
%DMTRAIN = dlmread( strcat( './KMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './KM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==7
% For GAK Kernel bandwidth, 26 overall
% 1-20, 0.01 0.05 0.1 0.25 0.5 0.75
%DMTRAIN = dlmread( strcat( './KMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './KM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_',num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==8
% For LCSS delta and espilon, 40 overall
%
% delta
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==9
% For TWED lambda and nu, 30 overall
%
% lambda
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==10
% For DISSIM
%
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==11
% For TQUEST
%
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==12
% For Swale
%
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==13
% For KDTW
%
%DMTRAIN = dlmread( strcat( './KMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './KM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==14
% For ERP
%
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
elseif DistanceIndex==15
% For Lorentzian
%
%DMTRAIN = dlmread( strcat( './DMCBFBIG/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_Train.distmatrix' ) );
DMTESTTOTRAIN = dlmread( strcat( './DM/',char(Datasets(i)),'/', char(Datasets(i)),'_',char(Methods(DistanceIndex)),'_', num2str(Param1),'_', num2str(Param2), '_TestToTrain.distmatrix' ) );
end
end
function [Params,Params2] = DistanceToParameter(DistanceIndex)
if DistanceIndex==1
Params = 0;
Params2 = 0;
elseif DistanceIndex==2
Params = 0;
Params2 = 0;
elseif DistanceIndex==3
% MSM - 10 Parameters
%Params = [0.01,0.1,1,10,100,0.05,0.5,5,50,500];
Params = 0.5;
Params2 = 0;
elseif DistanceIndex==4
% DTW - 0-20, 100 - 22 Parameters
%Params = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,100];
Params = 10;
Params2 = 0;
elseif DistanceIndex==5
% EDR - 20 Parameters
%Params = [0.001,0.003,0.005,0.007,0.009,0.01,0.03,0.05,0.07,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
Params = 0.1;
Params2 = 0;
elseif DistanceIndex==6
% SINK
%Params = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
Params = 5;
Params2 = 0;
elseif DistanceIndex==7
% For GAK Kernel bandwidth, 26 overall
% 1-20, 0.01 0.05 0.1 0.25 0.5 0.75
%Params = [0.01,0.05,0.1,0.25,0.5,0.75,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20];
Params = 0.1;
Params2 = 0;
elseif DistanceIndex==8
% For LCSS delta and espilon, 40 overall
%
% delta
%Params = [5,10];
Params = 5;
% epsilon
%Params2 = [0.001,0.003,0.005,0.007,0.009,0.01,0.03,0.05,0.07,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
Params2 = [0.2];
elseif DistanceIndex==9
% For TWED lambda and nu, 30 overall
%
% lambda
%Params = [0, 0.25, 0.5, 0.75, 1.0];
Params = [1.0];
% nu
%Params2 = [0.00001, 0.0001, 0.001, 0.01, 0.1, 1];
Params2 = [0.0001];
elseif DistanceIndex==10
% For DISSIM
%
Params = 0;
Params2 = 0;
elseif DistanceIndex==11
% For TQUEST
%
%Params = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2];
Params = [0.0200000000000000,0.0400000000000000,0.0600000000000000,0.0800000000000000,0.100000000000000,0.120000000000000,0.140000000000000,0.160000000000000,0.180000000000000,0.200000000000000,0.220000000000000,0.240000000000000,0.260000000000000,0.280000000000000,0.300000000000000,0.320000000000000,0.340000000000000,0.360000000000000,0.380000000000000,0.400000000000000,0.420000000000000,0.440000000000000,0.460000000000000,0.480000000000000,0.500000000000000,0.520000000000000,0.540000000000000,0.560000000000000,0.580000000000000,0.600000000000000,0.620000000000000,0.640000000000000,0.660000000000000,0.680000000000000,0.700000000000000,0.720000000000000,0.740000000000000,0.760000000000000,0.780000000000000,0.800000000000000,0.820000000000000,0.840000000000000,0.860000000000000,0.880000000000000,0.900000000000000,0.920000000000000,0.940000000000000,0.960000000000000,0.980000000000000,1];
Params2 = 0;
elseif DistanceIndex==12
% For Swale
%
%Params = [0.01,0.03,0.05,0.07,0.09,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1];
Params = 0.2;
Params2 = 0;
elseif DistanceIndex==13
% For KDTW
%
%Params = [2^-15,2^-14,2^-13,2^-12,2^-11,2^-10,2^-9,2^-8,2^-7,2^-6,2^-5,2^-4,2^-3,2^-2,2^-1,2^0,2^1,2^2,2^3,2^4];
%Params = [2^-15,2^-14,2^-13,2^-12,2^-11,2^-10,2^-9,2^-8,2^-7,2^-6,2^-5,2^-4,2^-3];
Params = 2^-3;
Params2 = 0;
elseif DistanceIndex==14
% For ERP
%
Params = 0;
Params2 = 0;
elseif DistanceIndex==15
% For Lorentzian
%
Params = 0;
Params2 = 0;
end
end