Calculates the forecastability of a moving window. Args: ts: time series window: length of slices jump: skipped step when taking subslices Returns: a list of forecastability measures for all slices.
(ts, window, jump=1)
| 27 | |
| 28 | |
| 29 | def forecastabilty_moving(ts, window, jump=1): |
| 30 | """Calculates the forecastability of a moving window. |
| 31 | |
| 32 | Args: |
| 33 | ts: time series |
| 34 | window: length of slices |
| 35 | jump: skipped step when taking subslices |
| 36 | |
| 37 | Returns: |
| 38 | a list of forecastability measures for all slices. |
| 39 | """ |
| 40 | |
| 41 | # ts = Trend(ts).detrend() |
| 42 | if len(ts) <= 25: |
| 43 | return forecastabilty(ts) |
| 44 | fore_lst = np.array([ |
| 45 | forecastabilty(ts[i - window:i]) |
| 46 | for i in np.arange(window, len(ts), jump) |
| 47 | ]) |
| 48 | fore_lst = fore_lst[~np.isnan(fore_lst)] # drop nan |
| 49 | return fore_lst |
| 50 | |
| 51 | |
| 52 | class Trend(): |
nothing calls this directly
no test coverage detected