Time Series Analysis and Forecasting
- Import the necessary libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics import mean_squared_error
from math import sqrt
from statsmodels.tsa.arima_model import ARIMA
- Load the data, can be found here
- Explore the dataset
- Convert the date column to datetime and set as the index
- Plot the data for all the columns
- Identify Trends in Time Series
- Identify Seasonal Patterns in Time Series
- Create a separate dataframe to hold only the gym records
- Separate the gym dataset into training and testing data, the test data will be for the year
2017
.
train = gym[gym.index.year < 2017]
test = gym[gym.index.year == 2017]
- Perform Forecasting on the gym dataset with each of the following methods:
- Method 1 – Start with a Naive Approach
- Method 2 – Simple average
- Method 3 – Moving average
- Method 4 – Single Exponential smoothing
- Plot for each method the graph showing the actual values along with the projected values.
- For each of the methods keep track of the RMSE to compare the performance