# Optimal seasonality (frequency) value for Holt-Winters in time series prediction [duplicate]

I am trying to use Holt-Winters method in order to do time-series prediction on some datasets. The problem that I'm dealing with is the fact that each dataset has different seasonality value (or frequency basically). As an example, in one dataset the trend occurs every 300 timesteps while for another one this might be a different number. Assuming that I do not have the option of visualizing data each time to find out about the seasonality of my data, what would be the best way for finding the optimal value of frequency to get the best performance from Holt-Winters? Note that I receive about 500 out of 4000 samples to train my model.

My approach: Split train data to train and validation subsets. Use different seasonality values on train and evaluate performance on validation. For now, I think I'll use random search to find the best value such that it minimizes the prediction error on validation set. I was wondering if there are any other practical methods or approaches that any of you might be aware of?

UPDATE: I have to mention that I have to implement this only in python and not R, so the findfrequency() function from forecast package is applicable here.

• Rob J. Hyndman has an algorithm for finding frequency based on spectral decomposition, as described in his blog post "Measuring time series characteristics". – Richard Hardy Aug 1 '16 at 18:30
• @RichardHardy thanks for your feedback but I'm not using R and would like something preferably in python. So implementing this in python is not what I'm looking for. – ahajib Aug 1 '16 at 19:56
• Software implementation is unfortunately off topic here. Probably you could still try to understand the R code to get the idea, then you could recode it in another language if you wish to. See also my answer here. – Richard Hardy Aug 2 '16 at 9:27
• @RichardHardy That is correct, but my question is not a programming or implementation problem. Btw, I tried the findfrequency function just to have an estimation of frequency of my data and unfortunately, it is not close to the actual value. – ahajib Aug 2 '16 at 13:45
• I see, sorry about that. Probably Rob J. Hyndman would be interested in that if you can supply your data to make the example reproducible. I suppose he would like to see cases where the algorithm fails so as to be able to improve the algorithm. – Richard Hardy Aug 2 '16 at 13:53