-
Notifications
You must be signed in to change notification settings - Fork 36
/
RunLOOCandOneNNDTW.m
55 lines (36 loc) · 2.12 KB
/
RunLOOCandOneNNDTW.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
function RunLOOCandOneNNDTW(DataSetStartIndex, DataSetEndIndex)
% first 2 values are '.' and '..' - UCR Archive 2018 version has 128 datasets
dir_struct = dir('/rigel/dsi/users/ikp2103/VLDBGRAIL/UCR2018/');
Datasets = {dir_struct(3:130).name};
% Sort Datasets
[Datasets, DSOrder] = sort(Datasets);
for i = 1:length(Datasets)
if (i>=DataSetStartIndex && i<=DataSetEndIndex)
LeaveOneOutAccuracies = zeros(length(Datasets),20);
LeaveOneOutRuntimes = zeros(length(Datasets),20);
Results = zeros(length(Datasets),6);
disp(['Dataset being processed: ', char(Datasets(i))]);
DS = LoadUCRdataset(char(Datasets(i)));
TSLength = length(DS.Data(1,:));
for gamma=1:20
gammaTmp = gamma-1
window = floor(gammaTmp/100 * TSLength);
tic;
acc = LOOClassifierDTW(DS,window);
LeaveOneOutRuntimes(i,gamma) = toc;
LeaveOneOutAccuracies(i,gamma) = acc;
end
[MaxLeaveOneOutAcc,MaxLeaveOneOutAccGamma] = max(LeaveOneOutAccuracies(i,:));
tic;
window = floor((MaxLeaveOneOutAccGamma-1)/100 * TSLength);
OneNNAcc = OneNNClassifierDTW(DS,window);
Results(i,1) = MaxLeaveOneOutAccGamma-1;
Results(i,2) = MaxLeaveOneOutAcc;
Results(i,3) = LeaveOneOutRuntimes(i,MaxLeaveOneOutAccGamma);
Results(i,4) = sum(LeaveOneOutRuntimes(i,:));
Results(i,5) = OneNNAcc;
Results(i,6) = toc;
dlmwrite( strcat('/rigel/dsi/users/ikp2103/VLDBGRAIL/RunLOOCandOneNNDTW/', 'RunLOOCandOneNNDTW_Dataset_', num2str(i)), Results, 'delimiter', '\t');
end
end
end