How to evaluate timeseries models using BIC?

This recipe helps you evaluate timeseries models using BIC

Recipe Objective

The Bayesian Information Criterion (BIC) is an index used in Bayesian statistics to choose between two or more alternative models. Comparing models with the Bayesian information criterion simply involves calculating the BIC for each model. The model with the lowest BIC is considered the best.

So this recipe is a short example on how to evaluate time series models using BIC. Let's get started.

Get Access to Time Series Analysis Real World Projects in Python

Step 1 - Import the library

import numpy as np import pandas as pd from statsmodels.tsa.arima_model import ARIMA

Let's pause and look at these imports. Numpy and pandas are general ones. Here matplotlib.pyplot will help us in plotting. statsmodels.tsa.arima_model will help us in model building.

Step 2 - Setup the Data

df = pd.read_csv('https://raw.githubusercontent.com/selva86/datasets/master/a10.csv', parse_dates=['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 - Calculating BIC

for i in range(0,2): for j in range(0,2): for k in range(0,2): model = ARIMA(df.value, order=(i, j, k)).fit() print(model.bic)

Best BIC can easily be calcuated through libraries. Here we have tried to understand what actually is happening inside. With variation of values of orders, BIC can be seen varying.

Step 4 - Lets look at our dataset now

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

1316.66388768731
1162.0554484438037
913.5172157072849
868.8258162104078
918.9268418564968
888.116114839384
889.526006058412
857.0907664191164

Clearly, order (1,1,1) is best fitted solution to our model. It can be extended further to 2 degrees to have a better understanding of results.

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Build a Customer Churn Prediction Model using Decision Trees
Develop a customer churn prediction model using decision tree machine learning algorithms and data science on streaming service data.

Build a Graph Based Recommendation System in Python -Part 1
Python Recommender Systems Project - Learn to build a graph based recommendation system in eCommerce to recommend products.

Build OCR from Scratch Python using YOLO and Tesseract
In this deep learning project, you will learn how to build your custom OCR (optical character recognition) from scratch by using Google Tesseract and YOLO to read the text from any images.

Llama2 Project for MetaData Generation using FAISS and RAGs
In this LLM Llama2 Project, you will automate metadata generation using Llama2, RAGs, and AWS to reduce manual efforts.

Build Portfolio Optimization Machine Learning Models in R
Machine Learning Project for Financial Risk Modelling and Portfolio Optimization with R- Build a machine learning model in R to develop a strategy for building a portfolio for maximized returns.

Langchain Project for Customer Support App in Python
In this LLM Project, you will learn how to enhance customer support interactions through Large Language Models (LLMs), enabling intelligent, context-aware responses. This Langchain project aims to seamlessly integrate LLM technology with databases, PDF knowledge bases, and audio processing agents to create a comprehensive customer support application.

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

Build a Similar Images Finder with Python, Keras, and Tensorflow
Build your own image similarity application using Python to search and find images of products that are similar to any given product. You will implement the K-Nearest Neighbor algorithm to find products with maximum similarity.

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.