-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommands.py
158 lines (139 loc) · 3.56 KB
/
commands.py
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
import fire
import numpy as np
from mimics.classifiers import clfs_full, scores
from mimics.experiments import (
CrossvalidatedCsp,
DrawKeypoints,
GridSearch,
WindowedCorrelations,
)
from mimics.transformers.extractors import inds_68
from mimics.types import Device
from mimics.utils import data_dir
points = {'brows': 'brows', 'smile': 'lips'}
exercises = {'brows': 'B', 'smile': 'S'}
cutoffs = {'brows': (0.45, 5.0), 'smile': (0.65, 6.0)}
def gridsearch(
dataset: str,
exercise: str,
cv: int = 5,
n_jobs: int = 1,
device: Device = 'cpu',
verbose: bool = False,
):
GridSearch(
f'{exercise}_{dataset}',
data_dir / dataset,
'fa',
points[exercise],
cutoffs[exercise],
exercises[exercise],
'hypomimia',
clfs=clfs_full,
scores=scores,
cv=cv,
n_jobs=n_jobs,
device=device,
verbose=verbose,
).evaluate()
def low_gridsearch(
dataset: str,
exercise: str,
high: float = 4.0,
cv: int = 5,
n_jobs: int = 1,
device: Device = 'cpu',
verbose: bool = False,
):
for low in np.arange(0.1, 1, 0.1):
GridSearch(
f'low_{exercise}_{dataset}',
data_dir / dataset,
'fa',
points[exercise],
(low, high),
exercises[exercise],
'hypomimia',
clfs=clfs_full,
scores=scores,
cv=cv,
n_jobs=n_jobs,
device=device,
verbose=verbose,
).evaluate()
def high_gridsearch(
dataset: str,
exercise: str,
low: float = 0.4,
cv: int = 5,
n_jobs: int = 1,
device: Device = 'cpu',
verbose: bool = False,
):
for high in np.arange(2, 10, 1):
GridSearch(
f'high_{exercise}_{dataset}',
data_dir / dataset,
'fa',
points[exercise],
(low, high),
exercises[exercise],
'hypomimia',
clfs=clfs_full,
scores=scores,
cv=cv,
n_jobs=n_jobs,
device=device,
verbose=verbose,
).evaluate()
def plot_csp(dataset: str, exercise: str, cv: int = 5, verbose: bool = False):
CrossvalidatedCsp(
f'csp_{exercise}_{dataset}',
data_dir / dataset,
'fa',
points[exercise],
(0.4, 3.0),
exercises[exercise],
'hypomimia',
cv=cv,
verbose=verbose,
log=False,
).evaluate()
def corrs_brows(dataset: str, verbose: bool = False):
WindowedCorrelations(
f'corrs_brows_{dataset}',
data_dir / dataset,
'fa',
'all',
(0.45, 5.0),
exercises['brows'],
'hypomimia',
windows=(1, 1.5, 2),
axes=(1,),
right_points=inds_68['right_brow'],
left_points=inds_68['left_brow'],
verbose=verbose,
log=False,
).evaluate()
def corrs_smile(dataset: str, verbose: bool = False):
WindowedCorrelations(
f'corrs_smile_{dataset}',
data_dir / dataset,
'fa',
'all',
(0.65, 6.0),
exercises['smile'],
'hypomimia',
windows=(1.5,),
axes=(0, 1),
right_points=inds_68['right_lips'],
left_points=inds_68['left_lips'],
verbose=verbose,
log=False,
).evaluate()
def draw_points(dataset: str, n_jobs: int = 1, verbose: bool = False):
DrawKeypoints(
data_dir / dataset, cutoff=2.5, n_jobs=n_jobs, verbose=verbose
).evaluate()
if __name__ == "__main__":
fire.Fire()