# How to classify time series trends into 2 groups: “contain seasonality” and “doesn't contain seasonality”

I'm optimizing prediction model for time series data trends. Each trend may have seasonality effect or may not. I want to classify each trend into one of the following groups: "seasonality" or "no seasonality". What is the best way to classify trends into those group?

I have tried already to calculate the variance of each trend but it is not good enough. More complex solution is to use Kmeans or PCA but maybe there can be another solution.

• as a first starting point, you can have a look here: stats.stackexchange.com/questions/241590/… – PV8 Jun 18 '19 at 12:29
• Thanks, but I don't care about what seasonality there is, all I care is if there is seasonality or not. – Aline Jun 18 '19 at 12:40
• I think the adequate tool would be a Fourier transformation of your time series. After transforming you should check the power at period of 1 year and if it is significantly different than zero then you have seasonality in your time series. – nukimov Jun 18 '19 at 12:45

There are multiple statistical tests for seasonality. For instance, auto.arima() in the forecast package for R uses an OCSB test, and Rob Hyndman explained why he switched to it from the Canova-Hansen test here.

To add to Stephans post, in python you can run the package:

import statsmodels.api as sm

• True, but I assume that similar to R's stl(), this will show a seasonal component whether or not it exists. – Stephan Kolassa Jun 18 '19 at 12:48