18
18
19
19
class Smoother :
20
20
"""
21
- This is the smoothing utility class. It handles imputation and smoothing.
22
- Reasonable defaults are given for all the parameters, but fine-grained
21
+ This is the smoothing utility class. It handles imputation and smoothing.
22
+ Reasonable defaults are given for all the parameters, but fine-grained
23
23
control is exposed.
24
-
24
+
25
25
Instantiating a smoother class specifies a smoother with a host of parameters,
26
26
which can then be applied to an np.ndarray with the function smooth:
27
27
> smoother = Smoother(method_name='savgol', window_length=28, gaussian_bandwidth=100)
@@ -51,8 +51,6 @@ class Smoother:
51
51
28 579
52
52
35 905
53
53
42 1303
54
- 49 1774
55
- 56 2318
56
54
impute: bool
57
55
If True, will fill nan values before smoothing. Currently uses the 'savgol' method
58
56
for imputation.
@@ -72,8 +70,8 @@ def __init__(
72
70
self ,
73
71
method_name = "savgol" ,
74
72
poly_fit_degree = 2 ,
75
- window_length = 42 ,
76
- gaussian_bandwidth = 325 , # corresponds to 95% weight on first 3 weeks
73
+ window_length = 28 ,
74
+ gaussian_bandwidth = 144 , # a ~2 week window
77
75
impute = True ,
78
76
minval = None ,
79
77
boundary_method = "shortened_window" ,
@@ -127,17 +125,17 @@ def smooth(self, signal):
127
125
128
126
def moving_average_smoother (self , signal ):
129
127
"""
130
- Compute a moving average on signal.
128
+ Computes a moving average on the signal.
131
129
132
130
Parameters
133
131
----------
134
132
signal: np.ndarray
135
- Input array
133
+ Input array.
136
134
137
135
Returns
138
136
-------
139
137
signal_smoothed: np.ndarray
140
- An array with the same length as arr, but the first window_length-1
138
+ An array with the same length as arr, but the first window_length-1
141
139
entries are np.nan.
142
140
"""
143
141
if not isinstance (self .window_length , int ):
0 commit comments