What is seasonal ARIMA model How to use it?

This recipe explains what is seasonal ARIMA model is and helps you use it

Recipe Objective

A seasonal ARIMA model is formed by including additional seasonal terms in the ARIMA models. The additional seasonal terms are simply multiplied by the non-seasonal terms.

So this recipe is a short example on What is seasonal ARIMA model and how to use it. Let's get started.

Step 1 - Import the library

import numpy as np import pandas as pd from statsmodels.tsa.seasonal import seasonal_decompose import matplotlib.pyplot as plt

Let's pause and look at these imports. Numpy and pandas are general ones. Here, seasonal_decompose will help us in understanding the seasonilty of data.

Step 2 - Setup the Data

df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/a10.csv', parse_dates=['date']).set_index('date')

Here, we have used one time series data from github. Also, we have set our index to date.

Now our dataset is ready.

Step 3 - Plotting the pattern

decomposition = seasonal_decompose(df.value, freq=12) fig = plt.figure() fig = decomposition.plot() fig.set_size_inches(20, 10)

Here, we have broken our datset using seasonal_decompose into trend, residual and seasonal. Residual is the stationary pattern and will almost remain constant. Seasonal is what our seasonal pattern will be. Trend is just our upward or downward movement with time.

Step 4 - Creating Seasonal Dataframe

trend = decomposition.trend seasonal = decomposition.seasonal residual = decomposition.resid print(seasonal)

Apart from visualizing our pattern, we have produced various dataframes based on their patter. Finally, we have printed down our seasonal dataframe.

Step 5 - Lets look at our dataset now

Once we run the above code snippet, we will see:

Srcoll down the ipython file to visualize the results.

Seasonal, Residual and Trend is visible. Also, we have produced our seasonal dataset in one separte dataframe for further analysis if needed.

What Users are saying..

profile image

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

AWS Project to Build and Deploy LSTM Model with Sagemaker
In this AWS Sagemaker Project, you will learn to build a LSTM model on Sagemaker for sales forecasting while analyzing the impact of weather conditions on Sales.

Build a Multi ClassText Classification Model using Naive Bayes
Implement the Naive Bayes Algorithm to build a multi class text classification model in Python.

Abstractive Text Summarization using Transformers-BART Model
Deep Learning Project to implement an Abstractive Text Summarizer using Google's Transformers-BART Model to generate news article headlines.

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Multi-Class Text Classification with Deep Learning using BERT
In this deep learning project, you will implement one of the most popular state of the art Transformer models, BERT for Multi-Class Text Classification

Build a Graph Based Recommendation System in Python-Part 2
In this Graph Based Recommender System Project, you will build a recommender system project for eCommerce platforms and learn to use FAISS for efficient similarity search.

House Price Prediction Project using Machine Learning in Python
Use the Zillow Zestimate Dataset to build a machine learning model for house price prediction.

GCP MLOps Project to Deploy ARIMA Model using uWSGI Flask
Build an end-to-end MLOps Pipeline to deploy a Time Series ARIMA Model on GCP using uWSGI and Flask

Learn to Build a Siamese Neural Network for Image Similarity
In this Deep Learning Project, you will learn how to build a siamese neural network with Keras and Tensorflow for Image Similarity.