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

Function forecastabilty

utils/data_analysis.py:6–26  ·  view source on GitHub ↗

Forecastability Measure. Args: ts: time series Returns: 1 - the entropy of the fourier transformation of time series / entropy of white noise

(ts)

Source from the content-addressed store, hash-verified

4
5
6def forecastabilty(ts):
7 """Forecastability Measure.
8
9 Args:
10 ts: time series
11
12 Returns:
13 1 - the entropy of the fourier transformation of
14 time series / entropy of white noise
15 """
16 ts = (ts - ts.min())/(ts.max()-ts.min()+0.1)
17 # fourier_ts = np.fft.rfft(ts).real
18 fourier_ts = abs(np.fft.rfft(ts))
19 fourier_ts = (fourier_ts - fourier_ts.min()) / (
20 fourier_ts.max() - fourier_ts.min())
21 fourier_ts /= fourier_ts.sum()
22 entropy_ts = entropy(fourier_ts)
23 fore_ts = 1-entropy_ts/(np.log(len(ts)))
24 if np.isnan(fore_ts):
25 return 0
26 return fore_ts
27
28
29def forecastabilty_moving(ts, window, jump=1):

Callers 1

forecastabilty_movingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected