Time Series Forecasting - Project Report

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 68

1

Final Project Report

Project - Time Series Forecasting – Wine Sales Analysis

MACHINE LEARNING

Nabeel Ahmed Khan

Oct ‘21

Date: 25/10/2021
2

Table of Contents

Table of Contents.......................................................................................................................2
Table of Figures.........................................................................................................................3
1. Executive Summary............................................................................................................4
2. Introduction.........................................................................................................................4
3. Data Details.........................................................................................................................4
4. Read the data as an appropriate Time Series data and plot the data...................................5
4.1 Reading the Data.........................................................................................................5
4.2 Plotting the Data..........................................................................................................5
5. Perform appropriate Exploratory Data Analysis to understand the data and also perform
decomposition............................................................................................................................7
5.1. EDA.............................................................................................................................7
Null Value Check................................................................................................................7
Duplicate Value Check.......................................................................................................7
Data Description.................................................................................................................8
Yearly Box Plots.................................................................................................................8
Monthly Box Plots............................................................................................................10
Monthly Sales Across Years.............................................................................................11
Yearly Sum of Observations.............................................................................................13
Mean of Observations of each Year.................................................................................14
Sum of Observations of each Quarter...............................................................................15
5.2. Decomposition...........................................................................................................15
6. Split the data into training and test. The test data should start in 1991............................18
7. Build various exponential smoothing models on the training data and evaluate the model
using RMSE on the test data. Other models such as Regression, Naïve forecast models and
simple average models should also be built on the training data and check the performance on
the test data using RMSE.........................................................................................................21
7.1 Linear Regression......................................................................................................21
7.2 Naïve Model..............................................................................................................24
7.3 Simple Average Model..............................................................................................26
7.4 Moving Average Model............................................................................................29
Moving Average Model on the Rose Wine dataset:.........................................................32
Simple Average Model on the Sparkling Wine dataset:...................................................33
7.5 Simple Exponential Smoothing (SES)......................................................................34
7.6 Double Exponential Smoothing (DES).....................................................................38
3

7.7 Triple Exponential Smoothing (TES)........................................................................41


7.8 Summary of all Models.............................................................................................44
8. heck for the stationarity of the data on which the model is being built on using
appropriate statistical tests and also mention the hypothesis for the statistical test. If the data
is found to be non-stationary, take appropriate steps to make it stationary. Check the new data
for stationarity and comment. Note: Stationarity should be checked at alpha = 0.05..............46
9. Build an automated version of the ARIMA/SARIMA model in which the parameters are
selected using the lowest Akaike Information Criteria (AIC) on the training data and evaluate
this model on the test data using RMSE..................................................................................50
9.1 ARIMA Model..........................................................................................................50
9.2 SARIMA Model........................................................................................................55

Table of Figure

Figure 1: Reading Wine Datasets...............................................................................................6


Figure 2: Rose Wine Time Series Plot.......................................................................................7
Figure 3: Sparkling Wine Time Series Plot...............................................................................7
Figure 4: Null Value Check.......................................................................................................8
Figure 5: Null Value Check.......................................................................................................8
Figure 6: Wine Sales Time Series Data Description..................................................................9
Figure 7: Yearly Box Plots.......................................................................................................10
Figure 8: Monthly Box Plots....................................................................................................11
Figure 9: Monthly Sales Across Years - Rose Wine................................................................13
Figure 10: Monthly Sales Across Years - Sparkling Wine......................................................13
Figure 11: Sum of Yearly Observations for Rose and Sparkling Wine...................................14
Figure 12: Mean of Observations of each Year.......................................................................15
Figure 13: Sum of Observations of each Quarter.....................................................................16
Figure 14: Additive Decomposition - Rose and Sparkling Wine............................................17
Figure 15: Multiplicative Decomposition - Rose and Sparkling Wine....................................18
Figure 16: Training and Test Datasets for Rose and Sparkling Wine Time Series.................20
Figure 17: Plots for Training and Test data frames..................................................................21
Figure 18: Training and Test data for Linear Regression........................................................23
Figure 19: Linear Regrsn Outcome on the Rose and Sparkling Wine Time Series respectively
..................................................................................................................................................24
Figure 20: Performance of the Linear Regression Model........................................................25
Figure 21: Training and Test data for Naive Model................................................................25
Figure 22: Naive Model Outcome on the Rose and Sparkling Wine Time Series respectively
..................................................................................................................................................26
Figure 23: Performance of the two Models..............................................................................26
Figure 24: Training and Test data for Simple Average Model................................................28
Figure 25: Simple Average Model Outcome on the Rose and Sparkling Wine Time Series
respectively..............................................................................................................................29

Figure 27: Moving Average Model Data for Rose and Sparkling wine respectively..............31
4

Figure 28: Moving Average Model Outcome on the Rose wine Time Series.........................32
Figure 29: Moving Average Model Outcome on the Sparkling Wine Time Series.................33
Figure 30: Summarized Performance of the Models...............................................................35
Figure 31: SES Parameters for the Rose and Sparkling wine datasets respectively................36
Figure 32: SES Train and Test data for Rose and Sparkling wine respectively......................37
Figure 33: Simple Exponential Smoothing Outcome on the Rose wine Time Series.............37
Figure 34: Simple Exponential Smoothing Outcome on the Sparkling Wine Time Series.....38
Figure 35: Summarized Performance of the Models...............................................................39
Figure 36: Alpha Beta values for Rose and Sparkling wine respectively................................40
Figure 37: Double Exponential Smoothing Outcome on the Rose wine Time Series.............41
Figure 38: Double Exponential Smoothing Outcome on the Sparkling Wine Time Series.....41
Figure 39: Summarized Performance of the Models...............................................................42
Figure 40: TES Parameters for the Rose and Sparkling wine datasets respectively................43
Figure 41: TES Model Train and Test data for Rose and Sparkling wine respectively...........43
Figure 42: Triple Exponential Smoothing Outcome on the Rose wine Time Series...............44
Figure 43: Triple Exponential Smoothing Outcome on the Sparkling Wine Time Series.......44
Figure 44: Summarized Performance of the Models...............................................................45
Figure 45: Sorted Model Performance Summary for Rose Wine Time Series........................46
Figure 46: Sorted Model Performance Summary for Sparkling Wine Time Series................46
Figure 47: Stationarity - Rose..................................................................................................48
Figure 48: Stationarity Check - Sparkling...............................................................................49
Figure 49: Running Automated ARIMA Model on Rose Wine Dataset.................................52
Figure 50: Results of Automated ARIMA Model on Rose Wine Dataset...............................53
Figure 51: Running Automated ARIMA Model on Sparkling Wine Dataset..........................54
Figure 52: Results of Automated ARIMA Model on Sparkling Wine Dataset.......................55
Figure 53:SARIMA Model on Rose wine data.........................................................................59
Figure 54: SARIMA Model on Sparkling Data.......................................................................62

Table of Tables

Table 1: Dataset Sample.............................................................................................................5


5

1. Executive Summary

For the Time Series Forecasting project, we have been provided with the data of different

types of wine sales in the 20th century. Both of these datasets are from the same company but

for different wines. As an analyst in the ABC Estate Wines, I need to analyse and forecast

Wine Sales in the 20th century.

2. Introduction

The intent for this project is to perform forecasting analysis on the Rose and Sparkling

dataset. I will try to analyse this dataset by using Linear Regression, Naïve Model, Simple

and Moving Average models, Simple, Double and Triple Exponential Smoothing. These

datasets contains 187 entries each, and I will try to build the most optimum model(s) on the

complete data and predict 12 months into the future with appropriate confidence

intervals/bands.

3. Data Details

Each datasets contain two columns, where the first column shows the month and year of the

corresponding Sales Quantity recorded in the second column.

YearMonth Rose YearMonth Sparkling


1980-01 112 1980-01 1686
1980-02 118 1980-02 1591
1980-03 129 1980-03 2304
1980-04 99 1980-04 1712
1980-05 116 1980-05 1471
1980-06 168 1980-06 1377
1980-07 118 1980-07 1966

Table 1: Wine Datasets Details


6

4. Read the data as an appropriate Time Series data and plot the data

4.1 Reading the Data

I have imported both the data series in two different ways. As we can observe, each entry

has an YearMonth value with it, which is not really a datapoint, but an index for the sales

entry. So in reality the datasets have a single column that contains the quantity of wines

sold in that particular month. Here, while reading the datasets into df_rose1 and

df_spark1 I have given the argument in a way so that it parses the first column which is

date column, and indicates to the system that this is a one column series through squeeze.

Figure 1: Reading Wine Datasets

It can be observed that both the datasets have data starting from January 1980 going till

July 1995, so there are 187 entries in totality in each dataset.

4.2 Plotting the Data

Now that I have uploaded the df_rose2 and df_spark2 datasets with no arguments (and

hence uploaded the datasets without parsing the dates here), I will need to provide a time

stamp value by ourselves. In addition to that I have removed the YearMonth variable and

added a time stamp to the dataset myself.

I have plotted both the time series below.


7

Figure 2: Rose Wine Time Series Plot

Figure 3: Sparkling Wine Time Series Plot

As we can observe from the above plots, the sales for Rose Wine are showing a declining

trend and the sales for Sparkling wines are showing an upward trend. There is a certain

seasonality element that is visible in the graphs. We will explore the trend and

seasonality further during decomposition, where we will be able to view a much detailed

report on these two factors.


8

5. Perform appropriate Exploratory Data Analysis to understand the data

and also perform decomposition

5.1. EDA

Null Value Check


Performing a Null value check on both the time series, I got:

Figure 4: Null Value Check

As we can see, the Rose dataset contains 2 Null values and there are no Null values for

Sparkling dataset; I addressed the Rose dataset Null values using linear interpolation so

as to obtain the imputed values in place of the values that are missing.

Post the imputation, I confirmed that there are no more Null values in the Rose dataset.

Figure 5: Null Value Check

Duplicate Value Check

There are no duplicate entries in the datasets as each value correspond to a different time

index, so basically these are all sales figures for different months.
9

Data Description

Figure 6: Wine Sales Time Series Data Description


As we can see from the above, both the wine sales time series data look like they are

skewed. There is High Standard Deviation for both ethe time series since the Min and

Max have significant difference between them. Moreover, there is difference between the

mean and the median for the same reason of skewness. As mentioned earlier, there are in

total 187 records in both the datasets.

Yearly Box Plots

Following are the yearly boxplots for the two wine sales time-series:
10

Figure 7: Yearly Box Plots


As we can observe from the above plots, Rose wine has mostly a downward sales trend.

The highest sales for Rose wine can be observed in 1981 and the lowest sales in 1994

(because the 1995 sales seem to be doing well, considering the data is only till July

month and reaching to the 1994 level already in 7 months itself). The highest variation in

monthly sales for Rose wine seems to be in the year 1981 and on the year 1994 there

seems to be the lowest variation in monthly sales.

As we can observe, the Sparkling Wine sales have a variation each year, the years 1985

and 1986 seem to be the years with the least variation, so the 2 years show certain

consistency in terms of sales. The highest sales for Sparkling Wine seems to happen in

the year 1994 and the lowest in the year 1982. Based on the 1995 data of 7 months (till

July), it is difficult to comment on the sales performance of that year. The Sparkling

wine sales appear to be going down from the year 1980 and have started increasing from
11

the year 1983. The variation in Sparkling Wine sales seem to be increasing for the period

1983-1986, while the highest variation in Sparkling wine sales is in the year 1994. There

is clear skewness that can be observed for Sparkling wine sales for all the years, except

maybe in 1981. There are outliers in the yearly sales data, however as it is a Time Series,

we can ignore the outlier data.

Monthly Box Plots

Following are the monthly boxplots for the two wine sales time-series:

Text(0, 0.5, 'Rose Wine Sales Monthly Variation')

Text(0, 0.5, 'Sparkling Wine Sales Monthly Variation')

Figure 8: Monthly Box Plots


As we can observe from the Monthly Box Plots, we can clearly see that there is a

seasonality element visible in both the Rose as well as Sparkling Wine time series

datasets. The Sparkling wine seem to have a higher seasonality element as compared to
12

Rose Wine. As can be clearly seen that the sales have an increasing sales trend in the last

quarter of the year, with Sparkling wine observing a steeper rise in sales during last

quarter. The sales for Rose wine seems to pick up from January month and is more or

less consistent till June, observes some stagnancy till September month and then starts to

pick up again from October (i.e. last quarter); while for Sparkling wine, the sales is

relatively low in first two quarters, slowly picks up pace during the third quarter and goes

on a rise till the end of the year. Monthly sales data for both the type of wines shows

skewness without much exceptions.

Monthly Sales Across Years

The monthly sales for the type of wines across years can be seen in the following Pivot

Tables and the associated graphs:


13

Figure 9: Monthly Sales Across Years - Rose Wine

Figure 10: Monthly Sales Across Years - Sparkling Wine


14

As can be observed from the above two sets of tables and graphs, the months of

December seems to be the month that drives the highest sales figures for both Rose and

Sparkling Wines. The second highest sales for Sparkling being in November while Rose

wine shows a mixed trend, with highest sales in August or July for certain years.

We can observe a seasonality element in the graphs for both Rose and Sparkling wines.

Yearly Sum of Observations

The yearly sum of sales numbers can be observed in the following tables and graphs:

Figure 11: Sum of Yearly Observations for Rose and Sparkling Wine
As can be observed from the above summation tables and the plotted graphs, Rose wine

annual sales year on year observe a downward sales trend. While the sales figures for
15

Sparkling wine show a dip initially with sales picking up from the year 1982 right up to

the year 1988 and then observing another dip in the sales. The steep drop post 1994 for

both Rose and Sparkling wine is because of the relatively less (half year data - till July)

data available for the year 1995.

Mean of Observations of each Year

The yearly mean for the sales figures can be observed below:

Figure 12: Mean of Observations of each Year


From the above tables and graphs, we can confirm the observations from the previous

section. An added observation would be that the mean sales for Rose wine are much

lesser than that of Sparkling wines.


16

Sum of Observations of each Quarter

The quarterly sum of sales numbers can be observed in the following tables and graphs:

Figure 13: Sum of Observations of each Quarter


From the above tables and graphs showing the quarterly sum of sales figures for both the

datasets, we can observe that the Quarterly sales show a downward trend for Rose wine

and an upward trend for Sparkling wine. Also there is a slight element of seasonality in

both the time series datasets.

5.2. Decomposition

I have provided the decomposed elements for both the Time Series below:
17

Figure 14: Additive Decomposition - Rose and Sparkling Wine


18

Figure 15: Multiplicative Decomposition - Rose and Sparkling Wine


We can see the decomposition of the two time series above. I have tried with both

additive and multiplicative decomposition for both time series so that I can determine if

the wine datasets are a multiplicative or additive series.


19

As we can observe from the above, we can say that the wine time series are clearly

multiplicative in nature and both have a seasonal component.

We can also observe again that the Rose wine sales depict a downward sales trend and

the Sparkling wine sales show an upward sales trend. The plots above clearly indicate

that the Wine sales are unstable and not uniform, and they have an apparent seasonality

trend. Moreover, the seasonal variation seems to be more in the case of Sparkling wine

as compared to the Rose wine; while the sales variation seems to be more in case of Rose

wine as compared to Sparkling wine.

6. Split the data into training and test. The test data should start in 1991.

I have split the time series datasets into Train and Test datasets below. It is given the

question that the Test Data should start in 1991, so I have used 71% of the datasets for

the Training dataset (instead of the usual 70%) and the rest of the dataset for Test

datasets.
20
21

Figure 16: Training and Test Datasets for Rose and Sparkling Wine Time Series
I have also confirmed that the Train dataset indeed ends in 1990, and the Test dataset

indeed starts in 1991 by using the Head and Tail functions on the Training and Test

datasets. As we can observe, the size of the Train data frame is 132 observations and that

of the Test data frame is 55 observations.

I have also plotted the Train and test data frames for both time series datasets below:

Figure 17: Plots for Training and Test data frames


22

We can observe the training and test data in the above plots, the Orange part of the plots

depicts the Train datasets (January ’80 – December ‘90), and the Blue part of the plots

depict the test datasets(January ’91 – July ‘95).

7. Build various exponential smoothing models on the training data and

evaluate the model using RMSE on the test data. Other models such as

Regression, Naïve forecast models and simple average models should

also be built on the training data and check the performance on the test

data using RMSE

In this section I will try to run the various available models on both the Rose and

Sparkling wine time series. Let’s kick off the analysis with Linear Regression model.

7.1 Linear Regression

The extracts of Training and Test data for the Linear Regression can be seen below:
23

Figure 18: Training and Test data for Linear Regression


24

Following are the results from a Linear Regression model run on both the Rose and

Sparkling Wine datasets:

Figure 19: Linear Regrsn Outcome on the Rose and Sparkling Wine Time Series respectively

The Regression plots above depict the regression on training set as the Red line and that

on the test set as the blue line. As we can observe from the above plots and metrics, Rose

wine sales show a downward trend, and the Sparkling wine sales show an upward trend.

For RegressionOnTime forecast on the Test Data for Rose wine,

RMSE = 15.433 | MAPE = 23.33.

For RegressionOnTime forecast on the Test Data for Sparkling wine,

RMSE = 1386.836 | MAPE = 50.02


25

The summarized performance of the models run on the two wine datasets can be seen

below:

Figure 20: Performance of the Linear Regression Model

7.2 Naïve Model

The extracts of Training and Test data for the Naïve Model can be seen below:

Figure 21: Training and Test data for Naive Model


Following are the results from running a Naïve Model on both the Rose and Sparkling

Wine datasets:
26

Figure 22: Naive Model Outcome on the Rose and Sparkling Wine Time Series respectively
For Rose Wine,

RMSE = 79.71877337417347 | MAPE = 145.1

For Sparkling Wine,

RMSE = 3864.2793518443914 | MAPE = 152.87

Figure 23: Performance of the two Models


27

As can be seen from the Naïve model performance for Rose and Sparkling wine datasets

above, the Naïve model is not suitable for any of the wine datasets since the forecasts

depends on the previous last observation.

7.3 Simple Average Model

The extracts of Training and Test data for the Simple Average Model can be seen below:
28

Figure 24: Training and Test data for Simple Average Model
Following are the results from running a Simple Average Model on both the Rose and

Sparkling Wine datasets:


29

Figure 25: Simple Average Model Outcome on the Rose and Sparkling Wine Time Series
respectively
For Simple Average Model on the Rose Wine dataset,

RMSE = 53.460569646114436 | MAPE = 94.93

For Simple Average Model on the Sparkling Wine dataset,


30

RMSE = 1275.0818036965309 | MAPE = 38.9

The summarized performance of the models run on the two wine datasets can be seen

below:

Figure 26: Performance of the three Models


As can be seen from the Simple Average model performance for Rose and Sparkling

wine datasets above, the Linear Regression model has the best performance among all

the three models run till now for the Rose wine dataset; while the Simple Average model

shows the best performance among all the three models run till now for the Sparkling

wine dataset.

7.4 Moving Average Model

The Moving Average data for the Rose and Sparkling wine datasets can be seen below:
31
32

Figure 27: Moving Average Model Data for Rose and Sparkling wine respectively
Following are the results from running a Moving Average Model on both the Rose and

Sparkling Wine datasets:


33

Figure 28: Moving Average Model Outcome on the Rose wine Time Series
34

Figure 29: Moving Average Model Outcome on the Sparkling Wine Time Series
Moving Average Model on the Rose Wine dataset:

For 2 point Moving Average Model forecast on the Training Data, RMSE = 11.529 |

MAPE = 13.54

For 4 point Moving Average Model forecast on the Training Data, RMSE = 14.451 |

MAPE = 19.49

For 6 point Moving Average Model forecast on the Training Data, RMSE = 14.566 |

MAPE = 20.82
35

For 9 point Moving Average Model forecast on the Training Data, RMSE = 14.728 |

MAPE = 21.01

Simple Average Model on the Sparkling Wine dataset:

For 2 point Moving Average Model forecast on the Training Data, RMSE = 813.401 |

MAPE = 19.70

For 4 point Moving Average Model forecast on the Training Data, RMSE = 1156.590 |

MAPE = 35.96

For 6 point Moving Average Model forecast on the Training Data, RMSE = 1283.927 |

MAPE = 43.86

For 9 point Moving Average Model forecast on the Training Data, RMSE = 1346.278 |

MAPE = 46.86

The summarized performance of the models run on the wine datasets can be seen below:
36

Figure 30: Summarized Performance of the Models


I have applied 2, 4, 6- and 9-point trailing averages on the both the Rose and Sparkling

wine data sets.

As we can observe from the above plots, all of the trailing average plots show prediction

values below the actual train and test data sets, and the 9 point trailing average plot

shows the lowest prediction of all the plots. The closest prediction to actual data is shown

by the 2 point trailing moving average model. This observation is corroborated by the

RMSE scores for each of these moving average models.

As can be seen from the summarized performance of all the models, the 2 point moving

average has shown the best performance of all the models run on the Rose and Sparkling

wine datasets.

7.5 Simple Exponential Smoothing (SES)

The SES Parameters for the Rose and Sparkling wine datasets can be seen below:
37

Figure 31: SES Parameters for the Rose and Sparkling wine datasets respectively
The SES train and test data for the Rose and Sparkling wine datasets can be seen below:
38

Figure 32: SES Train and Test data for Rose and Sparkling wine respectively
Following are the results from running a SES Model on both the Rose and Sparkling

Wine datasets:
39

Figure 33: Simple Exponential Smoothing Outcome on the Rose wine Time Series

Figure 34: Simple Exponential Smoothing Outcome on the Sparkling Wine Time Series
For Rose Wine dataset:

For Alpha =0.99 Simple Exponential Smoothening Model forecast on the Test data,

RMSE = 36.796 | MAPE = 63.88

For Sparkling Wine dataset:

For Alpha =0.99 Simple Exponential Smoothening Model forecast on the Test data,

RMSE = 1275.082 | MAPE = 38.90


40

The summarized performance of the models run on the wine datasets can be seen below:

Figure 35: Summarized Performance of the Models


As we all know that SES model should be used on data which has no element of trend or

seasonality, I still applied it on the both the Rose and Sparkling wine data sets so as to

see what’s the performance of the model in this case.

I used Alpha = 1 for the SES model and as expected, it did not perform well as compared

to previously run models.

7.6 Double Exponential Smoothing (DES)

The Alpha, Beta values for the Rose and Sparkling wine datasets can be seen below:
41
42

Figure 36: Alpha Beta values for Rose and Sparkling wine respectively
Following are the results from running a DES Model on both the Rose and Sparkling

Wine datasets:
43

Figure 37: Double Exponential Smoothing Outcome on the Rose wine Time Series

Figure 38: Double Exponential Smoothing Outcome on the Sparkling Wine Time Series
For Rose Wine dataset:

For Alpha = 0.3, Beta = 0.3 Double Exponential Smoothening Model forecast on the

Test data, RMSE = 265.567594 | MAPE = 442.50

For Sparkling Wine dataset:

For Alpha = 0.3, Beta = 0.3 Simple Exponential Smoothening Model forecast on the Test

data, RMSE = 18259.110704 | MAPE = 675.28


44

The summarized performance of the models run on the wine datasets can be seen below:

Figure 39: Summarized Performance of the Models


As we all know that DES model should be used on data which has no seasonality but has

levels and trends, I used the grid search to begin and we reached conclusion that Alpha =

0.3 and Beta = 0.3 show the lowest RMSE and MAPE for both the Rose and Sparkling

wine data sets. The DES model is the model with the worst performance so far for both

Rose and Sparkling wine datasets.

7.7 Triple Exponential Smoothing (TES)

The TES Parameters for the Rose and Sparkling wine datasets can be seen below:
45

Figure 40: TES Parameters for the Rose and Sparkling wine datasets respectively
The TES train and test data for the Rose and Sparkling wine datasets can be seen below:
46

Figure 41: TES Model Train and Test data for Rose and Sparkling wine respectively
Following are the results from running a SES Model on both the Rose and Sparkling

Wine datasets:
47

Figure 42: Triple Exponential Smoothing Outcome on the Rose wine Time Series

Figure 43: Triple Exponential Smoothing Outcome on the Sparkling Wine Time Series
For Rose Wine dataset:

For Alpha=0.106, Beta=0, Gamma=0.048, Triple Exponential Smoothing Model forecast

on the Test, RMSE = 17.369 | MAPE = 28.88

For Sparkling Wine dataset:

For Alpha=0.154, Beta=0.371, Gamma=7.413, Triple Exponential Smoothing Model

forecast on the Test, RMSE = 384.198 | MAPE = 11.94


48

The summarized performance of the models run on the wine datasets can be seen below:

Figure 44: Summarized Performance of the Models

7.8 Summary of all Models

Now that we have run all the models planned, let’s view the summary of the performance

in decreasing order for both the datasets:


49

Figure 45: Sorted Model Performance Summary for Rose Wine Time Series

Figure 46: Sorted Model Performance Summary for Sparkling Wine Time Series
As we can observe that for the Rose wine dataset, the 2 point trailing moving average

gives the best RMSE and MAPE among all the models.
50

For the Sparkling wine dataset, the TES model offers the best RMSE and MAPE among

all the models.

8. heck for the stationarity of the data on which the model is being built on

using appropriate statistical tests and also mention the hypothesis for

the statistical test. If the data is found to be non-stationary, take

appropriate steps to make it stationary. Check the new data for

stationarity and comment. Note: Stationarity should be checked at alpha

= 0.05

I have performed the Stationarity Test on both the Rose and Sparkling wine data frames.

I have used an augmented Dickey-Fuller test on the Rose and Sparkling wine data sets to

check the stationarity. The Hypothesis is that the wine data is stationary, Alpha = 0.05
51

Figure 47: Stationarity - Rose


52

Figure 48: Stationarity Check - Sparkling


As we can observe from the above, we need to reject the Hypothesis since the p value

seems to be greater than alpha, hence we will have to stationaries the data. That is, the

data properties do not depend on the time when the data series is observed. This is

basically a hint of a seasonality/trend element in the dataset. After taking the difference
53

of 1 in between continuous observations to stationaries the data, we can observe that the

p-value appeared to be less than 0.05.


54

9. Build an automated version of the ARIMA/SARIMA model in which the

parameters are selected using the lowest Akaike Information Criteria

(AIC) on the training data and evaluate this model on the test data using

RMSE.

9.1 ARIMA Model


55
56

Figure 49: Running Automated ARIMA Model on Rose Wine Dataset


Following are the Results of ARIMA model in Rose wine dataset:

Figure 50: Results of Automated ARIMA Model on Rose Wine Dataset


57
58

Figure 51: Running Automated ARIMA Model on Sparkling Wine Dataset


Following are the Results of ARIMA model in Rose wine dataset:

Figure 52: Results of Automated ARIMA Model on Sparkling Wine Dataset


59

As we can see from the above, the lowest AIC recorded for Rose wine data is for p,d,q

values of 0,1,2 respectively and the lowest AIC is 1273.194 . The p value of coefficients

MA1 and MA2 are 0 and 0.013 which means that these are pretty significant. The RMSE

and MAPE values are:

RMSE: 15.618093 MAPE: 25.445891

The lowest AIC for Sparkling data is 2210.6 for p,d,q, values of 2,1,2 respectively. The p

values of AR1, AR2, MA1, MA2 is Zero, which makes them pretty significant. The

RMSE and MAPE values are:

RMSE: MAPE: 56.334738

1374.696495

9.2 SARIMA Model

Following is the outcome of SARIM Model run on Rose wine data:


60
61
62
63

Figure 53:SARIMA Model on Rose wine data

Following is the outcome of SARIMA Model run on Sparkling wine data:


64
65
66
67

Figure 54: SARIMA Model on Sparkling Data

As can be observed, for Rose dataset, the model with p,d,q, as 2,1,3 respectively has the

lowest AIC, which is 951.74. The p value of ar.S.L12 and ma.S.L12 is less than 0.05

which makes them pretty significant. The RMSE and MAPE values are

RMSE: 31.109618689658337

MAPE: 63.63047031555068

For the Sparkling Dataset, as can be observed, the model with p,d,q, as 2,1,3 respectively

has the lowest AIC, which is 1629.07. The p value of ar.S.L12 and ma.S.L12 is less than

0.05 which makes them pretty significant. The RMSE and MAPE values are

RMSE: 809.8955158780718

MAPE: 35.7387905706479

You might also like