How to evaluate timeseries models using BIC?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

How to evaluate timeseries models using BIC?

How to evaluate timeseries models using BIC?

This recipe helps you evaluate timeseries models using BIC

0

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.

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.

Relevant Projects

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.

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.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

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.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.