Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: freq T not understood. Please report if you think this in error. (seasonal_decompose)

I was trying out seasonal_decompose to decompose my time series. The data is perfect time series with frequency of '2T' i.e. 2 Minutes. From file tsatools.py (site-pkgs\statsmodels\tsa\tsatools.py), in line 655, I added the following. _ elif freq == 'T': return 6024752_ I added this from the following inference: Freq A means 1 year hence it returns 1. Q means quaterly and hence returns 4 M means monthly and hence returns 12 and so on. Therefore, T means per minute, hence 60247*365

When I do the above, I get following error: ValueError: Inferred frequency of index and frequency don't match. This function does not re-sample From line 70 in seasonal.py (statsmodel\tsa\seasonal.py) Because : variable freq is : <2 * Minutes> And variable pfreq is 2T 524160.

I mean seasonal decompose should be able to decompose timeseries of 1min frequency, and something seems to have changed. Please have a look at it, and let me know if I'm missing anything.

like image 762
Debasish Kanhar Avatar asked Mar 18 '16 12:03

Debasish Kanhar


1 Answers

I got the same problem, I think it's an internal problem since I test all the index data type. At the end, I tried this and it works.

import statsmodels.api as sm
decompfreq = 6*12
decomposition = sm.tsa.seasonal_decompose(ts3_log.values,freq=decompfreq)
trend = decomposition.trend

decompfreq is calculated based on the time window, which is 10 mins, so the freqency actually is half a day.

Hope this would help you

like image 150
Ian Zhang Avatar answered Nov 07 '22 04:11

Ian Zhang