What does it mean for a timeseries to have multiple seasonalities?

This recipe explains what does it mean for a timeseries to have multiple seasonalities

Recipe Objective

Consider sales data contains daily observations. It exhibits weekly and yearly seasonal patterns. It means we are dealing with time series containing multiple seasonal effects. Now this time series has multiple seasonities effects. It can best be cared by TBATS or BATS.

So this recipe is a short example on does a time series have multiple seasonalities? What does it mean?. Let's get started.

Step 1 - Import the library

import numpy as np import pandas as pd from tbats import BATS,TBATS

Let's pause and look at these imports. Numpy and pandas are general ones. bats will help us in building the model; make sure you have preinstalled it in your system.

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 - Splitting dataset

train_data = df[1:len(df)-12] test_data = df[len(df)-12:]

We have split our dataset into train and test samples.

Step 4 - Creating TBAT, BATS & predicting

estimator_tbats = TBATS(seasonal_periods=(7, 365.25)) model_tbats = estimator.fit(train_data) estimator_bats = BATS(seasonal_periods=(7, 365.25)) model_bats = estimator.fit(train_data) y_forecast_tbats = model_tbats.forecast(steps=365) y_forecast_bats = model_bats.forecast(steps=365) print(y_forecast_tbats) print(y_forecast_bats)

Simply, using TBATS/BATS library, we have created an object of TBATS/BATS class and thereby fit our datset on the train. Finally we are predicting the datset for the next 1 year (365 days).

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.

What Users are saying..

profile image

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

Deep Learning Project- Real-Time Fruit Detection using YOLOv4
In this deep learning project, you will learn to build an accurate, fast, and reliable real-time fruit detection system using the YOLOv4 object detection model for robotic harvesting platforms.

Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

Build a Speech-Text Transcriptor with Nvidia Quartznet Model
In this Deep Learning Project, you will leverage transfer learning from Nvidia QuartzNet pre-trained models to develop a speech-to-text transcriptor.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

Learn to Build an End-to-End Machine Learning Pipeline - Part 2
In this Machine Learning Project, you will learn how to build an end-to-end machine learning pipeline for predicting truck delays, incorporating Hopsworks' feature store and Weights and Biases for model experimentation.

Linear Regression Model Project in Python for Beginners Part 1
Machine Learning Linear Regression Project in Python to build a simple linear regression model and master the fundamentals of regression for beginners.

Recommender System Machine Learning Project for Beginners-1
Recommender System Machine Learning Project for Beginners - Learn how to design, implement and train a rule-based recommender system in Python

MLOps Project to Deploy Resume Parser Model on Paperspace
In this MLOps project, you will learn how to deploy a Resume Parser Streamlit Application on Paperspace Private Cloud.

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.