-
Notifications
You must be signed in to change notification settings - Fork 12
/
pre_process.m
44 lines (35 loc) · 921 Bytes
/
pre_process.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
data=[balanced_TrainData;balanced_TestData];
labels=[balanced_TrainData_targets;balanced_TestData_targets];
labels_1hot=zeros(size(labels,1),8);
idx_0=find(labels==0);
idx_1=find(labels==1);
idx_2=find(labels==2);
idx_3=find(labels==3);
idx_4=find(labels==4);
idx_5=find(labels==5);
idx_6=find(labels==6);
idx_7=find(labels==7);
for i=1:size(idx_0,1)
labels_1hot(idx_0(i),:)=[0,0,0,0,0,0,0,1];
end
for i=1:size(idx_1,1)
labels_1hot(idx_1(i),:)=[0,0,0,0,0,0,1,0];
end
for i=1:size(idx_2,1)
labels_1hot(idx_2(i),:)=[0,0,0,0,0,1,0,0];
end
for i=1:size(idx_3,1)
labels_1hot(idx_3(i),:)=[0,0,0,0,1,0,0,0];
end
for i=1:size(idx_4,1)
labels_1hot(idx_4(i),:)=[0,0,0,1,0,0,0,0];
end
for i=1:size(idx_5,1)
labels_1hot(idx_5(i),:)=[0,0,1,0,0,0,0,0];
end
for i=1:size(idx_6,1)
labels_1hot(idx_6(i),:)=[0,1,0,0,0,0,0,0];
end
for i=1:size(idx_7,1)
labels_1hot(idx_7(i),:)=[1,0,0,0,0,0,0,0];
end