In Machine Learning, a seasonal autoregressive integrated moving average (SARIMA) model is a different step from an ARIMA model based on the concept of seasonal trends. In this article, I will introduce you to the SARIMA model in machine learning.
What is the SARIMA Model?
Seasonal variations of the time series can take into account periodic models, allowing more accurate predictions. Seasonal ARIMA (SARIMA) defines both a seasonal and a non-seasonal component of the ARIMA model, allowing periodic characteristics to be captured.
Also, Read – How To Launch Your Machine Learning Model?
By choosing an appropriate forecasting model, always visualize your data to identify trends, seasons and cycles. If seasonality is a strong feature of the series, consider models with seasonal adjustments such as the SARIMA model.
SARIMA Model in Action
In this article, I will use the number of tourist arrivals in Italy. The data is taken from European statistics: annual data on tourism industries. You can download this dataset from here. First, we import the data set for foreign tourist arrivals in Italy from 2012 to October 2019 and then convert it to a time series.
Let’s get started with the task by importing and reading the data:
The preliminary analysis is a visual analysis of the time series, to understand its trend and behaviour. First, we create the time series and store it in the variable ts.
Now, let’s tune the parameters:
from statsmodels.tsa.stattools import adfuller def test_stationarity(timeseries): dftest = adfuller(timeseries, autolag='AIC') dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used']) for key,value in dftest.items(): dfoutput['Critical Value (%s)'%key] = value critical_value = dftest['5%'] test_statistic = dftest alpha = 1e-3 pvalue = dftest if pvalue < alpha and test_statistic < critical_value: # null hypothesis: x is non stationary print("X is stationary") return True else: print("X is not stationary") return FalseCode language: PHP (php)
We now need to transform the time series via the diff () function as many times as the time series becomes stationary:
ts_diff = pd.Series(ts) d = 0 while test_stationarity(ts_diff) is False: ts_diff = ts_diff.diff().dropna() d = d + 1Code language: PHP (php)
Now, let’s plot the correlations between the parameters:
Building the SARIMA Model:
Now, let’s build our model by using the SARIMAX method provided by the statsmodels library:
Now, we need to plot the results of our model:
Also, Read – Word Embeddings in Machine Learning.
I hope you liked this article on how we can build the SARIMA Model for seasonality effects. Feel free to ask your valuable questions in the comments section below. You can also follow me on Medium to learn every topic of Machine Learning.
Could you please provide IT_tourists_arrivals.csv file. I am unbale to retrieve it from Eurostats