forked from pminasandra/hyena-acc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeatures.py
67 lines (47 loc) · 2.25 KB
/
features.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
### This file is to contain ALL feature extraction code
### Write carefully. Ensure that every actual feature function takes a crawler object as an argument.
######################################## BASIC FUNCTIONS ###################################################################################
import numpy as np
def _avg(List):
return sum(List)/len(List)
def _var(List):
AVG = _avg(List)
VAR = 0
if len(List) in [0, 1]:
return 0.0
for x in List:
VAR += (x-AVG)**2
return VAR/(len(List)-1)
######################################## FEATURE FUNCTIONS ##################################################################################
def surge_mean(crawler_obj):
return _avg(crawler_obj.surge[~np.isnan(crawler_obj.surge)])
def surge_var(crawler_obj):
return _var(crawler_obj.surge[~np.isnan(crawler_obj.surge)])
def surge_max(crawler_obj):
return max(crawler_obj.surge[~np.isnan(crawler_obj.surge)])
def surge_min(crawler_obj):
return min(crawler_obj.surge[~np.isnan(crawler_obj.surge)])
def heave_mean(crawler_obj):
return _avg(crawler_obj.heave[~np.isnan(crawler_obj.heave)])
def heave_var(crawler_obj):
return _var(crawler_obj.heave[~np.isnan(crawler_obj.heave)])
def heave_max(crawler_obj):
return max(crawler_obj.heave[~np.isnan(crawler_obj.heave)])
def heave_min(crawler_obj):
return min(crawler_obj.heave[~np.isnan(crawler_obj.heave)])
def sway_mean(crawler_obj):
return _avg(crawler_obj.sway[~np.isnan(crawler_obj.sway)])
def sway_var(crawler_obj):
return _var(crawler_obj.sway[~np.isnan(crawler_obj.sway)])
def sway_max(crawler_obj):
return max(crawler_obj.sway[~np.isnan(crawler_obj.sway)])
def sway_min(crawler_obj):
return min(crawler_obj.sway[~np.isnan(crawler_obj.sway)])
def vedba_mean(crawler_obj):
return _avg(crawler_obj.vedba[~np.isnan(crawler_obj.vedba)])
def vedba_var(crawler_obj):
return _var(crawler_obj.vedba[~np.isnan(crawler_obj.vedba)])
def vedba_max(crawler_obj):
return max(crawler_obj.vedba[~np.isnan(crawler_obj.vedba)])
def vedba_min(crawler_obj):
return min(crawler_obj.vedba[~np.isnan(crawler_obj.vedba)])