-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain2layerRF.m
45 lines (38 loc) · 1.04 KB
/
train2layerRF.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
%% TRAINING
load('training.mat');
% train on dominant emotion
Mdl1 = trainRFModel( faces, 'dex_chalearn_features_fc7', 'label2', 100 );
Mdl2 = cell(7,1);
for kk=1:7
kk
% create subset with second emotion
n = 1;
for jj=1:length( faces )
%if( strcmp( faces{jj}.label1, num2str( kk ) ) )
if( strcmp( faces{jj}.label2, num2str( kk ) ) )
faces2{n} = faces{jj};
n = n+1;
end
end
Mdl2{ kk } = trainRFModel( faces2, 'dex_chalearn_features_fc7', 'label1', 100 );
end
%% VALIDATION
load( 'validation.mat' );
% apply all models
Y1 = applyModel( Mdl1, facesVal, 'dex_chalearn_features_fc7' );
Y2 = cell(7,1);
for kk=1:7
Y2{kk} = applyModel( Mdl2{ kk }, facesVal, 'dex_chalearn_features_fc7' );
end
for kk=1:length( facesVal )
if Y1{kk} == 'N'
Y{kk} = 'N_N';
else
Y{ kk } = [char( Y2{ grp2idx( Y1{ kk } )}(kk)) '_' char( Y1{ kk })];
end
end
fileID = fopen('predictions.txt','w');
for kk = 1:length( Y )
fprintf(fileID, '%s\n', Y{kk});
end
fclose( fileID );