MCPcopy Create free account
hub / github.com/kwuking/TimeMixer / forecastabilty_moving

Function forecastabilty_moving

utils/data_analysis.py:29–49  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

27
28
29def 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
52class Trend():

Callers

nothing calls this directly

Calls 1

forecastabiltyFunction · 0.85

Tested by

no test coverage detected