diff --git a/examples/README.md b/examples/README.md index 39b28c5b..d5fc5527 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,8 +1,8 @@ # Forecasting examples -This folder contains Python and R examples for building forecasting solutions presented in Python Jupyter notebooks and R Markdown files, respectively. The examples are organized according to forecasting scenarios in different use cases with each subdirectory under `examples/` named after the specific use case. +This folder contains Python and R examples for building forecasting solutions presented in Python Jupyter notebooks and R Markdown files, respectively. The examples are organized according to forecasting scenarios in different use cases with each subdirectory under `examples/` named after the specific use case. -At the moment, the repository contains a single retail sales forecasting scenario utilizing [Dominick's OrangeJuice data set](https://www.chicagobooth.edu/research/kilts/datasets/dominicks). The name of the directory is `grocery_sales`. +At the moment, the repository contains a single retail sales forecasting scenario utilizing [Dominick's OrangeJuice data set](https://www.chicagobooth.edu/research/kilts/datasets/dominicks). The name of the directory is `grocery_sales`. ## Summary diff --git a/examples/grocery_sales/R/01_dataprep.Rmd b/examples/grocery_sales/R/01_dataprep.Rmd index 05cd7d02..d4f2881d 100644 --- a/examples/grocery_sales/R/01_dataprep.Rmd +++ b/examples/grocery_sales/R/01_dataprep.Rmd @@ -4,7 +4,7 @@ output: html_notebook --- _Copyright (c) Microsoft Corporation._
-_Licensed under the MIT License._ +_Licensed under the MIT License._ In this notebook, we generate the datasets that will be used for model training and validating. diff --git a/examples/grocery_sales/R/01_dataprep.nb.html b/examples/grocery_sales/R/01_dataprep.nb.html index bf37aa54..3b86bdb0 100644 --- a/examples/grocery_sales/R/01_dataprep.nb.html +++ b/examples/grocery_sales/R/01_dataprep.nb.html @@ -4,194 +4,228 @@ - - - + + + + + + + Data preparation + + + + + + + + + + + + + + + + + + + + + + -Data preparation + - - + img { + max-width: 100%; + } + + .tabbed-pane { + padding-top: 12px; + } + + .html-widget { + margin-bottom: 20px; + } + + button.code-folding-btn:focus { + outline: none; + } + + summary { + display: list-item; + } + + + + - + + .tabset-dropdown>.nav-tabs>li.active { + display: block; + } - -.kable-table table>thead { - background-color: #fff; -} - - - - - - - - - + + @@ -201,97 +235,107 @@ summary { -
+
- - -

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

-

In this notebook, we generate the datasets that will be used for model training and validating.

-

The orange juice dataset comes from the bayesm package, and gives pricing and sales figures over time for a variety of orange juice brands in several stores in Florida. Rather than installing the entire package (which is very complex), we download the dataset itself from the GitHub mirror of the CRAN repository.

- - - -
# download the data from the GitHub mirror of the bayesm package source
+    
+    

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

+

In this notebook, we generate the datasets that will be used for model training and validating.

+

The orange juice dataset comes from the bayesm package, and gives pricing and sales figures over time for a + variety of orange juice brands in several stores in Florida. Rather than installing the entire package (which is + very complex), we download the dataset itself from the GitHub mirror of the CRAN repository.

+ + + +
# download the data from the GitHub mirror of the bayesm package source
 ojfile <- tempfile(fileext=".rda")
 download.file("https://github.com/cran/bayesm/raw/master/data/orangeJuice.rda", ojfile)
 load(ojfile)
 file.remove(ojfile)
- - - -

The dataset generation parameters are obtained from the file ojdata_forecast_settings.yaml; you can modify that file to vary the experimental setup. The settings are

- ----- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterDescriptionDefault
N_SPLITSThe number of splits to make.10
HORIZONThe forecast horizon for the test dataset for each split.2
GAPThe gap in weeks from the end of the training period to the start of the testing period; see below.2
FIRST_WEEKThe first week of data to use.40
LAST_WEEKThe last week of data to use.156
START_DATEThe actual calendar date for the start of the first week in the data.1989-09-14
-

A complicating factor is that the data does not include every possible combination of store, brand and date, so we have to pad out the missing rows with complete. In addition, one store/brand combination has no data beyond week 156; we therefore end the analysis at this week. We also do not fill in the missing values in the data, as many of the modelling functions in the fable package can handle this innately.

- - - -
library(tidyr)
+    
+    
+    
+    

The dataset generation parameters are obtained from the file ojdata_forecast_settings.yaml; you can + modify that file to vary the experimental setup. The settings are

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterDescriptionDefault
N_SPLITSThe number of splits to make.10
HORIZONThe forecast horizon for the test dataset for each split.2
GAPThe gap in weeks from the end of the training period to the start of the testing period; see below.2
FIRST_WEEKThe first week of data to use.40
LAST_WEEKThe last week of data to use.156
START_DATEThe actual calendar date for the start of the first week in the data.1989-09-14
+

A complicating factor is that the data does not include every possible combination of store, brand and date, so + we have to pad out the missing rows with complete. In addition, one store/brand combination has no + data beyond week 156; we therefore end the analysis at this week. We also do not fill in the missing + values in the data, as many of the modelling functions in the fable package can handle this innately.

+ + + +
library(tidyr)
 library(dplyr)
 library(tsibble)
 library(feasts)
@@ -307,33 +351,37 @@ oj_data <- orangeJuice$yx %>%
     complete(store, brand, week) %>%
     mutate(week=yearweek(start_date + week*7)) %>%
     as_tsibble(index=week, key=c(store, brand))
- - - -

Here are some glimpses of what the data looks like. The dependent variable is logmove, the logarithm of the total sales for a given brand and store, in a particular week.

- - - -
head(oj_data)
- -
- -
- - -

The time series plots for a small subset of brands and stores are shown below. We can make the following observations:

-
    -
  • There appears to be little seasonal variation in sales (probably because Florida is a state without very different seasons). In any case, with less than 2 years of observations, the time series is not long enough for many model-fitting functions in the fable package to automatically estimate seasonal parameters.
  • -
  • While some store/brand combinations show weak trends over time, this is far from universal.
  • -
  • Different brands can exhibit very different behaviour, especially in terms of variation about the mean.
  • -
  • Many of the time series have missing values, indicating that the dataset is incomplete.
  • -
- - - -
library(ggplot2)
+    
+ + +

The time series plots for a small subset of brands and stores are shown below. We can make the following + observations:

+
    +
  • There appears to be little seasonal variation in sales (probably because Florida is a state without very + different seasons). In any case, with less than 2 years of observations, the time series is not long enough for + many model-fitting functions in the fable package to automatically estimate seasonal parameters.
  • +
  • While some store/brand combinations show weak trends over time, this is far from universal.
  • +
  • Different brands can exhibit very different behaviour, especially in terms of variation about the mean.
  • +
  • Many of the time series have missing values, indicating that the dataset is incomplete.
  • +
+ + + +
library(ggplot2)
 
 oj_data %>%
     filter(store < 25, brand < 5) %>%
@@ -341,17 +389,30 @@ oj_data %>%
         geom_line() +
         scale_x_date(labels=NULL) +
         facet_grid(vars(store), vars(brand), labeller="label_both")
- - -

- - - -

Finally, we split the dataset into separate samples for training and testing. The schema used is broadly time series cross-validation, whereby we train a model on data up to time \(t\), test it on data for times \(t+1\) to \(t+k\), then train on data up to time \(t+k\), test it on data for times \(t+k+1\) to \(t+2k\), and so on. In this specific case study, however, we introduce a small extra piece of complexity based on discussions with domain experts. We train a model on data up to week \(t\), then test it on week \(t+2\) to \(t+3\). Then we train on data up to week \(t+2\), and test it on weeks \(t+4\) to \(t+5\), and so on. There is thus always a gap of one week between the training and test samples. The reason for this is because in reality, inventory planning always takes some time; the gap allows store managers to prepare the stock based on the forecasted demand.

- - - -
subset_oj_data <- function(start, end)
+    
+    
+    

+ + + +

Finally, we split the dataset into separate samples for training and testing. The schema used is broadly time + series cross-validation, whereby we train a model on data up to time \(t\), test + it on data for times \(t+1\) to \(t+k\), then + train on data up to time \(t+k\), test it on data for times \(t+k+1\) to \(t+2k\), and so on. In this specific + case study, however, we introduce a small extra piece of complexity based on discussions with domain experts. We + train a model on data up to week \(t\), then test it on week \(t+2\) to \(t+3\). Then we train on data up to week + \(t+2\), and test it on weeks \(t+4\) to \(t+5\), and so on. There is thus always a gap of one week between the training and + test samples. The reason for this is because in reality, inventory planning always takes some time; the gap allows + store managers to prepare the stock based on the forecasted demand.

+ + + +
subset_oj_data <- function(start, end)
 {
     start <- yearweek(start_date + start*7)
     end <- yearweek(start_date + end*7)
@@ -364,84 +425,87 @@ oj_test <- lapply(train_periods, function(i) subset_oj_data(i + settings$GAP,
 save(oj_train, oj_test, file=here::here("examples/grocery_sales/R/data.Rdata"))
 
 head(oj_train[[1]])
- -
- -
- -
head(oj_test[[1]])
- -
- -
- +
+ -
LS0tCnRpdGxlOiBEYXRhIHByZXBhcmF0aW9uCm91dHB1dDogaHRtbF9ub3RlYm9vawotLS0KCl9Db3B5cmlnaHQgKGMpIE1pY3Jvc29mdCBDb3Jwb3JhdGlvbi5fPGJyLz4KX0xpY2Vuc2VkIHVuZGVyI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cmUgbWFuYWdlcnMgdG8gcHJlcGFyZSB0aGUgc3RvY2sgYmFzZWQgb24gdGhlIGZvcmVjYXN0ZWQgZGVtYW5kLgoKYGBge3J9CnN1YnNldF9val9kYXRhIDwtIGZ1bmN0aW9uKHN0YXJ0LCBlbmQpCnsKICAgIHN0YXJ0IDwtIHllYXJ3ZWVrKHN0YXJ0X2RhdGUgKyBzdGFydCo3KQogICAgZW5kIDwtIHllYXJ3ZWVrKHN0YXJ0X2RhdGUgKyBlbmQqNykKICAgIGZpbHRlcihval9kYXRhLCB3ZWVrID49IHN0YXJ0LCB3ZWVrIDw9IGVuZCkKfQoKb2pfdHJhaW4gPC0gbGFwcGx5KHRyYWluX3BlcmlvZHMsIGZ1bmN0aW9uKGkpIHN1YnNldF9val9kYXRhKHNldHRpbmdzJEZJUlNUX1dFRUssIGkpKQpval90ZXN0IDwtIGxhcHBseSh0cmFpbl9wZXJpb2RzLCBmdW5jdGlvbihpKSBzdWJzZXRfb2pfZGF0YShpICsgc2V0dGluZ3MkR0FQLCBpICsgc2V0dGluZ3MkR0FQICsgc2V0dGluZ3MkSE9SSVpPTiAtIDEpKQoKc2F2ZShval90cmFpbiwgb2pfdGVzdCwgZmlsZT1oZXJlOjpoZXJlKCJleGFtcGxlcy9ncm9jZXJ5X3NhbGVzL1IvZGF0YS5SZGF0YSIpKQoKaGVhZChval90cmFpbltbMV1dKQoKaGVhZChval90ZXN0W1sxXV0pCmBgYAo= +
- + - + - + - + $(document).ready(function () { + $('.tabset-dropdown > .nav-tabs > li').click(function () { + $(this).parent().toggleClass('nav-tabs-open') + }); + }); + - - + + - - + + - + + \ No newline at end of file diff --git a/examples/grocery_sales/R/02_basic_models.Rmd b/examples/grocery_sales/R/02_basic_models.Rmd index 6dda9451..d541aa6b 100644 --- a/examples/grocery_sales/R/02_basic_models.Rmd +++ b/examples/grocery_sales/R/02_basic_models.Rmd @@ -4,7 +4,7 @@ output: html_notebook --- _Copyright (c) Microsoft Corporation._
-_Licensed under the MIT License._ +_Licensed under the MIT License._ ```{r, echo=FALSE, results="hide", message=FALSE} library(tidyr) diff --git a/examples/grocery_sales/R/02_basic_models.nb.html b/examples/grocery_sales/R/02_basic_models.nb.html index 6f91ee65..29ff3d83 100644 --- a/examples/grocery_sales/R/02_basic_models.nb.html +++ b/examples/grocery_sales/R/02_basic_models.nb.html @@ -4,194 +4,228 @@ - - - + + + + + + + Basic models + + + + + + + + + + + + + + + + + + + + + + -Basic models + - - + img { + max-width: 100%; + } + + .tabbed-pane { + padding-top: 12px; + } + + .html-widget { + margin-bottom: 20px; + } + + button.code-folding-btn:focus { + outline: none; + } + + summary { + display: list-item; + } + + + + - + + .tabset-dropdown>.nav-tabs>li.active { + display: block; + } - -.kable-table table>thead { - background-color: #fff; -} - - - - - - - - - + + @@ -201,54 +235,62 @@ summary { -
+
- - -

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

- - - - -

We fit some simple models to the orange juice data for illustrative purposes. Here, each model is actually a group of models, one for each combination of store and brand. This is the standard approach taken in statistical forecasting, and is supported out-of-the-box by the tidyverts framework.

-
    -
  • mean: This is just a simple mean.
  • -
  • naive: A random walk model without any other components. This amounts to setting all forecast values to the last observed value.
  • -
  • drift: This adjusts the naive model to incorporate a straight-line trend.
  • -
  • arima: An ARIMA model with the parameter values estimated from the data.
  • -
-

Note that the model training process is embarrassingly parallel on 3 levels:

-
    -
  • We have multiple independent training datasets;
  • -
  • For which we fit multiple independent models;
  • -
  • Within which we have independent sub-models for each store and brand.
  • -
-

This lets us speed up the training significantly. While the fable::model function can fit multiple models in parallel, we will run it sequentially here and instead parallelise by dataset. This avoids contention for cores, and also results in the simplest code. As a guard against returning invalid results, we also specify the argument .safely=FALSE; this forces model to throw an error if a model algorithm fails.

- - - -
srcdir <- here::here("R_utils")
+    
+    

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

+ + + + +

We fit some simple models to the orange juice data for illustrative purposes. Here, each model is actually a + group of models, one for each combination of store and brand. This is the standard approach taken in + statistical forecasting, and is supported out-of-the-box by the tidyverts framework.

+
    +
  • mean: This is just a simple mean.
  • +
  • naive: A random walk model without any other components. This amounts to setting all forecast + values to the last observed value.
  • +
  • drift: This adjusts the naive model to incorporate a straight-line trend.
  • +
  • arima: An ARIMA model with the parameter values estimated from the data.
  • +
+

Note that the model training process is embarrassingly parallel on 3 levels:

+
    +
  • We have multiple independent training datasets;
  • +
  • For which we fit multiple independent models;
  • +
  • Within which we have independent sub-models for each store and brand.
  • +
+

This lets us speed up the training significantly. While the fable::model function can fit multiple + models in parallel, we will run it sequentially here and instead parallelise by dataset. This avoids contention + for cores, and also results in the simplest code. As a guard against returning invalid results, we also specify + the argument .safely=FALSE; this forces model to throw an error if a model algorithm + fails.

+ + + +
srcdir <- here::here("R_utils")
 for(src in dir(srcdir, full.names=TRUE)) source(src)
 
 load_objects("grocery_sales", "data.Rdata")
@@ -273,20 +315,23 @@ save_objects(oj_modelset_basic, oj_fcast_basic,
 do.call(rbind, oj_fcast_basic) %>%
     mutate_at(-(1:3), exp) %>%
     eval_forecasts()
- -
- -
- - -

The ARIMA model does the best of the simple models, but not any better than a simple mean.

-

Having fit some basic models, we can also try an exponential smoothing model, fit using the ETS function. Unlike the others, ETS does not currently support time series with missing values; we therefore have to use one of the other models to impute missing values first via the interpolate function.

- - - -
oj_modelset_ets <- parallel::clusterMap(cl, function(df, basicmod)
+    
+ + +

The ARIMA model does the best of the simple models, but not any better than a simple mean.

+

Having fit some basic models, we can also try an exponential smoothing model, fit using the ETS + function. Unlike the others, ETS does not currently support time series with missing values; we + therefore have to use one of the other models to impute missing values first via the interpolate + function.

+ + + +
oj_modelset_ets <- parallel::clusterMap(cl, function(df, basicmod)
 {
     df %>%
         interpolate(object=select(basicmod, -c(mean, naive, drift))) %>%
@@ -306,79 +351,84 @@ save_objects(oj_modelset_ets, oj_fcast_ets,
 do.call(rbind, oj_fcast_ets) %>%
     mutate_at(-(1:3), exp) %>%
     eval_forecasts()
- -
- -
- - -

The ETS model does worse than the ARIMA model, something that should not be a surprise given the lack of strong seasonality and trend in this dataset. We conclude that any simple univariate approach is unlikely to do well.

- +
+ + +

The ETS model does worse than the ARIMA model, something that should not be a surprise given the lack of + strong seasonality and trend in this dataset. We conclude that any simple univariate approach is unlikely to do + well.

+ -
LS0tCnRpdGxlOiBCYXNpYyBtb2RlbHMKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKX0NvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLl88YnIvPgpfTGljZW5zZWQgdW5kZXIgdGhlIE1JVCBMaWNlbnNlLl8KCmBgYHtyLCBlY2hvPUZBTFNFLCByZXN1bHRzPSJoaWRlIiwgbWVzc2FnZT1GQUxTRX0KbGlicmFyeSh0aWR5cikKbGlicmFyeShkcGx5cikKbGlicmFyeSh0c2liYmxlKQpsaWJyYXJ5KGZlYXN0cykKbGlicmFyeShmYWJsZSkKYGBgCgpXZSBmaXQgc29tZSBzaW1wbGUgbW9kZWxzIHRvIHRoZSBvcmFuZ2UganVpY2UgZGF0YSBmb3IgaWxsdXN0cmF0aXZlIHB1cnBvc2VzLiBIZXJlLCBlYWNoIG1vZGVsIGlzIGFjdHVhbGx5IGEgX2dyb3VwXyBvZiBtb2RlbHMsIG9uZSBmb3IgZWFjaCBjb21iaW5hdGlvbiBvZiBzdG9yZSBhbmQgYnJhbmQuIFRoaXMgaXMgdGhlIHN0YW5kYXJkIGFwcHJvYWNoIHRha2VuIGluIHN0YXRpc3RpY2FsIGZvcmVjYXN0aW5nLCBhbmQgaXMgc3VwcG9ydGVkIG91dC1vZi10aGUtYm94IGJ5IHRoZSB0aWR5dmVydHMgZnJhbWV3b3JrLgoKLSBgbWVhbmA6IFRoaXMgaXMganVzdCBhIHNpbXBsZSBtZWFuLgotIGBuYWl2ZWA6IEEgcmFuZG9tIHdhbGsgbW9kZWwgd2l0aG91dCBhbnkgb3RoZXIgY29tcG9uZW50cy4gVGhpcyBhbW91bnRzIHRvIHNldHRpbmcgYWx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ml2YXJpYXRlIGFwcHJvYWNoIGlzIHVubGlrZWx5IHRvIGRvIHdlbGwuCg== +
- + - + - + - + $(document).ready(function () { + $('.tabset-dropdown > .nav-tabs > li').click(function () { + $(this).parent().toggleClass('nav-tabs-open') + }); + }); + - - + + - - + + - + + \ No newline at end of file diff --git a/examples/grocery_sales/R/02a_reg_models.Rmd b/examples/grocery_sales/R/02a_reg_models.Rmd index 581f4e35..4523e211 100644 --- a/examples/grocery_sales/R/02a_reg_models.Rmd +++ b/examples/grocery_sales/R/02a_reg_models.Rmd @@ -4,7 +4,7 @@ output: html_notebook --- _Copyright (c) Microsoft Corporation._
-_Licensed under the MIT License._ +_Licensed under the MIT License._ ```{r, echo=FALSE, results="hide", message=FALSE} library(tidyr) diff --git a/examples/grocery_sales/R/02a_reg_models.nb.html b/examples/grocery_sales/R/02a_reg_models.nb.html index f5e186af..a7f529b2 100644 --- a/examples/grocery_sales/R/02a_reg_models.nb.html +++ b/examples/grocery_sales/R/02a_reg_models.nb.html @@ -10,7 +10,6 @@ - ARIMA-Regression models diff --git a/examples/grocery_sales/R/02b_prophet_models.Rmd b/examples/grocery_sales/R/02b_prophet_models.Rmd index 0d416e11..19c4e215 100644 --- a/examples/grocery_sales/R/02b_prophet_models.Rmd +++ b/examples/grocery_sales/R/02b_prophet_models.Rmd @@ -4,7 +4,7 @@ output: html_notebook --- _Copyright (c) Microsoft Corporation._
-_Licensed under the MIT License._ +_Licensed under the MIT License._ ```{r, echo=FALSE, results="hide", message=FALSE} library(tidyr) diff --git a/examples/grocery_sales/R/02b_prophet_models.nb.html b/examples/grocery_sales/R/02b_prophet_models.nb.html index 4bf9ae60..a254a83d 100644 --- a/examples/grocery_sales/R/02b_prophet_models.nb.html +++ b/examples/grocery_sales/R/02b_prophet_models.nb.html @@ -4,194 +4,228 @@ - - - + + + + + + + Prophet models + + + + + + + + + + + + + + + + + + + + + + -Prophet models + - - + img { + max-width: 100%; + } + + .tabbed-pane { + padding-top: 12px; + } + + .html-widget { + margin-bottom: 20px; + } + + button.code-folding-btn:focus { + outline: none; + } + + summary { + display: list-item; + } + + + + - + + .tabset-dropdown>.nav-tabs>li.active { + display: block; + } - -.kable-table table>thead { - background-color: #fff; -} - - - - - - - - - + + @@ -201,45 +235,53 @@ summary { -
+
- - -

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

- - - - -

This notebook builds a forecasting model using the Prophet algorithm. Prophet is a time series model developed by Facebook that is designed to be simple for non-experts to use, yet flexible and powerful.

-
-

Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well.

-
-

Here, we will use the fable.prophet package which provides a tidyverts frontend to the prophet package itself. As with ETS, prophet does not support time series with missing values, so we again impute them using the ARIMA model forecasts.

- - - -
srcdir <- here::here("R_utils")
+    
+    

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

+ + + + +

This notebook builds a forecasting model using the Prophet + algorithm. Prophet is a time series model developed by Facebook that is designed to be simple for non-experts to + use, yet flexible and powerful.

+
+

Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are + fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have + strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in + the trend, and typically handles outliers well.

+
+

Here, we will use the fable.prophet package which provides a tidyverts frontend to the prophet package itself. As + with ETS, prophet does not support time series with missing values, so we again impute them using the ARIMA model + forecasts.

+ + + +
srcdir <- here::here("R_utils")
 for(src in dir(srcdir, full.names=TRUE)) source(src)
 
 load_objects("grocery_sales", "data_reg.Rdata")
@@ -278,79 +320,85 @@ save_objects(oj_modelset_pr, oj_fcast_pr,
 do.call(rbind, oj_fcast_pr) %>%
     mutate_at(-(1:3), exp) %>%
     eval_forecasts()
- -
- -
- - -

It appears that Prophet does not do better than the simple ARIMA model with regression variables. This is possibly because the dataset does not have a strong time series nature: there is no seasonality, and only weak or nonexistent trends. These are features which the Prophet algorithm is designed to detect, and their absence means that there would be little advantage in using it.

- +
+ + +

It appears that Prophet does not do better than the simple ARIMA model with regression variables. This + is possibly because the dataset does not have a strong time series nature: there is no seasonality, and only weak + or nonexistent trends. These are features which the Prophet algorithm is designed to detect, and their absence + means that there would be little advantage in using it.

+ -
LS0tCnRpdGxlOiBQcm9waGV0IG1vZGVscwpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgpfQ29weXJpZ2h0IChjKSBNaWNyb3NvZnQgQ29ycG9yYXRpb24uXzxici8+Cl9MaWNlbnNlZCB1bmRlciB0aGUgTUlUIExpY2Vuc2UuXwoKYGBge3IsIGVjaG89RkFMU0UsIHJlc3VsdHM9ImhpZGUiLCBtZXNzYWdlPUZBTFNFfQpsaWJyYXJ5KHRpZHlyKQpsaWJyYXJ5KGRwbHlyKQpsaWJyYXJ5KHRzaWJibGUpCmxpYnJhcnkoZmVhc3RzKQpsaWJyYXJ5KGZhYmxlKQpsaWJyYXJ5KHByb3BoZXQpCmxpYnJhcnkoZmFibGUucHJvcGhldCkKYGBgCgpUaGlzIG5vdGVib29rIGJ1aWxkcyBhIGZvcmVjYXN0aW5nIG1vZGVsIHVzaW5nIHRoZSBbUHJvcGhldF0oaHR0cHM6Ly9mYWNlYm9vay5naXRodWIuaW8vcHJvcGhldC8pIGFsZ29yaXRobS4gUHJvcGhldCBpcyBhIHRpbWUgc2VyaWVzIG1vZGVsIGRldmVsb3BlZCBieSBGYWNlYm9vayB0aGF0IGlzIGRlc2lnbmVkIHRvIGJlIHNpbXBsZSBmb3Igbm9uLWV4cGVydHMgdG8gdXNlLCB5ZXQgZmxleGlibGUgYW5kIHBvd2VyZnVsLgoKPiBQcm9waGV0IGlzIGEgcHJvY2VkdXJlIGZvciBmb3JlY2FzdGluZyB0aW1lIHNlcmllcyBkYXRhIGJhc2VkIG9uIGFuIGFkZGl0aXZlIG1vZGVsIHdoZXJlIG5vbi1saW5lYXIgdHJlbmRzI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HRoYW4gdGhlIHNpbXBsZSBBUklNQSBtb2RlbCB3aXRoIHJlZ3Jlc3Npb24gdmFyaWFibGVzLiBUaGlzIGlzIHBvc3NpYmx5IGJlY2F1c2UgdGhlIGRhdGFzZXQgZG9lcyBub3QgaGF2ZSBhIHN0cm9uZyB0aW1lIHNlcmllcyBuYXR1cmU6IHRoZXJlIGlzIG5vIHNlYXNvbmFsaXR5LCBhbmQgb25seSB3ZWFrIG9yIG5vbmV4aXN0ZW50IHRyZW5kcy4gVGhlc2UgYXJlIGZlYXR1cmVzIHdoaWNoIHRoZSBQcm9waGV0IGFsZ29yaXRobSBpcyBkZXNpZ25lZCB0byBkZXRlY3QsIGFuZCB0aGVpciBhYnNlbmNlIG1lYW5zIHRoYXQgdGhlcmUgd291bGQgYmUgbGl0dGxlIGFkdmFudGFnZSBpbiB1c2luZyBpdC4K +
-
+ - + - + - + $(document).ready(function () { + $('.tabset-dropdown > .nav-tabs > li').click(function () { + $(this).parent().toggleClass('nav-tabs-open') + }); + }); + - - + + - - + + - + + \ No newline at end of file diff --git a/examples/grocery_sales/R/README.md b/examples/grocery_sales/R/README.md index 6e3ca408..5e389bd9 100644 --- a/examples/grocery_sales/R/README.md +++ b/examples/grocery_sales/R/README.md @@ -1,6 +1,6 @@ # Forecasting examples in R: orange juice retail sales -The Rmarkdown notebooks in this directory are as follows. Each notebook also has a corresponding HTML file, which is the rendered output from running the code. +The Rmarkdown notebooks in this directory are as follows. Each notebook also has a corresponding HTML file, which is the rendered output from running the code. - [`01_dataprep.Rmd`](01_dataprep.Rmd) creates the training and test datasets - [`02_basic_models.Rmd`](02_basic_models.Rmd) fits a range of simple time series models to the data, including ARIMA and ETS. diff --git a/examples/grocery_sales/R/forecast_settings.yaml b/examples/grocery_sales/R/forecast_settings.yaml index 638662ce..4526685f 100644 --- a/examples/grocery_sales/R/forecast_settings.yaml +++ b/examples/grocery_sales/R/forecast_settings.yaml @@ -3,4 +3,4 @@ HORIZON: 2 GAP: 2 FIRST_WEEK: 40 LAST_WEEK: 156 -START_DATE: "1989-09-14" +START_DATE: "1989-09-14" \ No newline at end of file diff --git a/examples/grocery_sales/README.md b/examples/grocery_sales/README.md index 8bcfb30c..1872c722 100644 --- a/examples/grocery_sales/README.md +++ b/examples/grocery_sales/README.md @@ -1,6 +1,6 @@ # Forecasting examples -This folder contains Python and R examples for building forecasting solutions on the Orange Juice dataset which is part of the [Dominick's dataset](https://www.chicagobooth.edu/research/kilts/datasets/dominicks). The examples are presented in Python Jupyter notebooks and R Markdown files, respectively. +This folder contains Python and R examples for building forecasting solutions on the Orange Juice dataset which is part of the [Dominick's dataset](https://www.chicagobooth.edu/research/kilts/datasets/dominicks). The examples are presented in Python Jupyter notebooks and R Markdown files, respectively. ## Orange Juice Dataset @@ -19,8 +19,8 @@ Note that the week number starts from 40 in this dataset, while the full Dominic The following summarizes each directory of the forecasting examples. -| Directory | Content | Description | -| --- | --- | --- | -| [python](./python)| [00_quick_start/](./python/00_quick_start)
[01_prepare_data/](./python/01_prepare_data)
[02_model/](./python/02_model)
[03_model_tune_deploy/](./python/03_model_tune_deploy/) |
  • Quick start examples for single-round training
  • Data exploration and preparation notebooks
  • Multi-round training examples
  • Model tuning and deployment example
| -| [R](./R) | [01_dataprep.Rmd](R/01_dataprep.Rmd)
[02_basic_models.Rmd](R/02_basic_models.Rmd)
[02a_reg_models.Rmd](R/02a_reg_models.Rmd)
[02b_prophet_models.Rmd](R/02b_prophet_models.Rmd) |
  • Data preparation
  • Basic time series models
  • ARIMA-regression models
  • Prophet models
| +| Directory | Content | Description | +|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [python](./python) | [00_quick_start/](./python/00_quick_start)
[01_prepare_data/](./python/01_prepare_data)
[02_model/](./python/02_model)
[03_model_tune_deploy/](./python/03_model_tune_deploy/) |
  • Quick start examples for single-round training
  • Data exploration and preparation notebooks
  • Multi-round training examples
  • Model tuning and deployment example
| +| [R](./R) | [01_dataprep.Rmd](R/01_dataprep.Rmd)
[02_basic_models.Rmd](R/02_basic_models.Rmd)
[02a_reg_models.Rmd](R/02a_reg_models.Rmd)
[02b_prophet_models.Rmd](R/02b_prophet_models.Rmd) |
  • Data preparation
  • Basic time series models
  • ARIMA-regression models
  • Prophet models
| diff --git a/examples/grocery_sales/python/00_quick_start/autoarima_single_round.ipynb b/examples/grocery_sales/python/00_quick_start/autoarima_single_round.ipynb index b9e7d81b..c403d8a7 100644 --- a/examples/grocery_sales/python/00_quick_start/autoarima_single_round.ipynb +++ b/examples/grocery_sales/python/00_quick_start/autoarima_single_round.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/00_quick_start/azure_automl_single_round.ipynb b/examples/grocery_sales/python/00_quick_start/azure_automl_single_round.ipynb index 50634b12..1c3f2b13 100644 --- a/examples/grocery_sales/python/00_quick_start/azure_automl_single_round.ipynb +++ b/examples/grocery_sales/python/00_quick_start/azure_automl_single_round.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/00_quick_start/lightgbm_single_round.ipynb b/examples/grocery_sales/python/00_quick_start/lightgbm_single_round.ipynb index d1597717..0a30d46f 100644 --- a/examples/grocery_sales/python/00_quick_start/lightgbm_single_round.ipynb +++ b/examples/grocery_sales/python/00_quick_start/lightgbm_single_round.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/01_prepare_data/ojdata_exploration.ipynb b/examples/grocery_sales/python/01_prepare_data/ojdata_exploration.ipynb index e40b1994..5daedf4f 100644 --- a/examples/grocery_sales/python/01_prepare_data/ojdata_exploration.ipynb +++ b/examples/grocery_sales/python/01_prepare_data/ojdata_exploration.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/01_prepare_data/ojdata_preparation.ipynb b/examples/grocery_sales/python/01_prepare_data/ojdata_preparation.ipynb index 0c9a2b03..38508ec6 100644 --- a/examples/grocery_sales/python/01_prepare_data/ojdata_preparation.ipynb +++ b/examples/grocery_sales/python/01_prepare_data/ojdata_preparation.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/02_model/autoarima_multi_round.ipynb b/examples/grocery_sales/python/02_model/autoarima_multi_round.ipynb index 7e076693..d57f850b 100644 --- a/examples/grocery_sales/python/02_model/autoarima_multi_round.ipynb +++ b/examples/grocery_sales/python/02_model/autoarima_multi_round.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/02_model/dilatedcnn_multi_round.ipynb b/examples/grocery_sales/python/02_model/dilatedcnn_multi_round.ipynb index 7bf98fca..48a41f47 100644 --- a/examples/grocery_sales/python/02_model/dilatedcnn_multi_round.ipynb +++ b/examples/grocery_sales/python/02_model/dilatedcnn_multi_round.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/02_model/lightgbm_multi_round.ipynb b/examples/grocery_sales/python/02_model/lightgbm_multi_round.ipynb index c33a9551..33cb1567 100644 --- a/examples/grocery_sales/python/02_model/lightgbm_multi_round.ipynb +++ b/examples/grocery_sales/python/02_model/lightgbm_multi_round.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/03_model_tune_deploy/aml_scripts/train_validate.py b/examples/grocery_sales/python/03_model_tune_deploy/aml_scripts/train_validate.py index a4148047..65a8bdd1 100644 --- a/examples/grocery_sales/python/03_model_tune_deploy/aml_scripts/train_validate.py +++ b/examples/grocery_sales/python/03_model_tune_deploy/aml_scripts/train_validate.py @@ -1,5 +1,5 @@ # Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. +# Licensed under the MIT License. """ Perform cross validation of a LightGBM forecasting model on the training data of the 1st forecast round. diff --git a/examples/grocery_sales/python/03_model_tune_deploy/azure_hyperdrive_lightgbm.ipynb b/examples/grocery_sales/python/03_model_tune_deploy/azure_hyperdrive_lightgbm.ipynb index a2399f57..8237e694 100644 --- a/examples/grocery_sales/python/03_model_tune_deploy/azure_hyperdrive_lightgbm.ipynb +++ b/examples/grocery_sales/python/03_model_tune_deploy/azure_hyperdrive_lightgbm.ipynb @@ -6,7 +6,7 @@ "source": [ "Copyright (c) Microsoft Corporation.\n", "\n", - "Licensed under the MIT License. " + "Licensed under the MIT License." ] }, { diff --git a/examples/grocery_sales/python/README.md b/examples/grocery_sales/python/README.md index 8e87201e..b7c41a6a 100644 --- a/examples/grocery_sales/python/README.md +++ b/examples/grocery_sales/python/README.md @@ -1,16 +1,16 @@ # Forecasting examples in Python -This folder contains Jupyter notebooks with Python examples for building forecasting solutions. To run the notebooks, please ensure your environment is set up with required dependencies by following instructions in the [Setup guide](../../../docs/SETUP.md). +This folder contains Jupyter notebooks with Python examples for building forecasting solutions. To run the notebooks, please ensure your environment is set up with required dependencies by following instructions in the [Setup guide](../../../docs/SETUP.md). ## Summary The following summarizes each directory of the Python best practice notebooks. -| Directory | Content | Description | -| --- | --- | --- | -| [00_quick_start](./00_quick_start)| [autoarima_single_round.ipynb](./00_quick_start/autoarima_single_round.ipynb)
[azure_automl_single_round.ipynb](./00_quick_start/azure_automl_single_round.ipynb)
[lightgbm_single_round.ipynb](./00_quick_start/lightgbm_single_round.ipynb) | Quick start notebooks that demonstrate workflow of developing a forecasting model using one-round training and testing data| -| [01_prepare_data](./01_prepare_data) | [ojdata_exploration.ipynb](./01_prepare_data/ojdata_exploration.ipynb)
[ojdata_preparation.ipynb](./01_prepare_data/ojdata_preparation.ipynb) | Data exploration and preparation notebooks| -| [02_model](./02_model) | [dilatedcnn_multi_round.ipynb](./02_model/dilatedcnn_multi_round.ipynb)
[lightgbm_multi_round.ipynb](./02_model/lightgbm_multi_round.ipynb)
[autoarima_multi_round.ipynb](./02_model/autoarima_multi_round.ipynb) | Deep dive notebooks that perform multi-round training and testing of various classical and deep learning forecast algorithms| -| [03_model_tune_deploy](./03_model_tune_deploy/) | [azure_hyperdrive_lightgbm.ipynb](./03_model_tune_deploy/azure_hyperdrive_lightgbm.ipynb)
[aml_scripts/](./03_model_tune_deploy/aml_scripts) |
  • Example notebook for model tuning using Azure Machine Learning Service and deploying the best model on Azure
  • Scripts for model training and validation
| +| Directory | Content | Description | +|-------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| [00_quick_start](./00_quick_start) | [autoarima_single_round.ipynb](./00_quick_start/autoarima_single_round.ipynb)
[azure_automl_single_round.ipynb](./00_quick_start/azure_automl_single_round.ipynb)
[lightgbm_single_round.ipynb](./00_quick_start/lightgbm_single_round.ipynb) | Quick start notebooks that demonstrate workflow of developing a forecasting model using one-round training and testing data | +| [01_prepare_data](./01_prepare_data) | [ojdata_exploration.ipynb](./01_prepare_data/ojdata_exploration.ipynb)
[ojdata_preparation.ipynb](./01_prepare_data/ojdata_preparation.ipynb) | Data exploration and preparation notebooks | +| [02_model](./02_model) | [dilatedcnn_multi_round.ipynb](./02_model/dilatedcnn_multi_round.ipynb)
[lightgbm_multi_round.ipynb](./02_model/lightgbm_multi_round.ipynb)
[autoarima_multi_round.ipynb](./02_model/autoarima_multi_round.ipynb) | Deep dive notebooks that perform multi-round training and testing of various classical and deep learning forecast algorithms | +| [03_model_tune_deploy](./03_model_tune_deploy/) | [azure_hyperdrive_lightgbm.ipynb](./03_model_tune_deploy/azure_hyperdrive_lightgbm.ipynb)
[aml_scripts/](./03_model_tune_deploy/aml_scripts) |
  • Example notebook for model tuning using Azure Machine Learning Service and deploying the best model on Azure
  • Scripts for model training and validation
| diff --git a/tests/ci/component_governance.yml b/tests/ci/component_governance.yml index 2a809587..f535927f 100644 --- a/tests/ci/component_governance.yml +++ b/tests/ci/component_governance.yml @@ -1,5 +1,5 @@ # Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. +# Licensed under the MIT License. # Pull request against these branches will trigger this build pr: diff --git a/tests/ci/cpu_integration_tests_linux.yml b/tests/ci/cpu_integration_tests_linux.yml index 8fc5bb1f..0f780c40 100644 --- a/tests/ci/cpu_integration_tests_linux.yml +++ b/tests/ci/cpu_integration_tests_linux.yml @@ -1,5 +1,5 @@ # Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. +# Licensed under the MIT License. # Pull request against these branches will trigger this build pr: diff --git a/tests/ci/cpu_unit_tests_linux.yml b/tests/ci/cpu_unit_tests_linux.yml index 3f66cba3..66c8f456 100644 --- a/tests/ci/cpu_unit_tests_linux.yml +++ b/tests/ci/cpu_unit_tests_linux.yml @@ -1,5 +1,5 @@ # Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. +# Licensed under the MIT License. # Pull request against these branches will trigger this build pr: diff --git a/tests/ci/python_unit_tests_base.yml b/tests/ci/python_unit_tests_base.yml deleted file mode 100644 index a677213d..00000000 --- a/tests/ci/python_unit_tests_base.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Pull request against these branches will trigger this build -#pr: -#- staging -#- master - -# Any commit to these branches will trigger the build. -#trigger: -#- staging -#- master - -pool: - name: ForecastingBP - vmImage: "forecastingtestmachine" - -steps: - -- bash: | - echo "##vso[task.prependpath]/data/anaconda/bin" - displayName: Add conda to PATH - -- bash: | - . /anaconda/etc/profile.d/conda.sh && \ - conda activate forecasting_base && \ - pytest tests/python/unit -m "not notebooks and not spark and not gpu" --junitxml=reports/python-unit-tests-base.xml && \ - conda deactivate - displayName: "Run unit tests" - -- task: PublishTestResults@2 - inputs: - testResultsFiles: "reports/python-unit-tests-base.xml" - testRunTitle: "Test results of unit tests" \ No newline at end of file diff --git a/tests/ci/r_unit_tests_base.yml b/tests/ci/r_unit_tests_base.yml deleted file mode 100644 index 3de175d8..00000000 --- a/tests/ci/r_unit_tests_base.yml +++ /dev/null @@ -1,31 +0,0 @@ -# Pull request against these branches will trigger this build -#pr: -#- staging -#- master - -# Any commit to these branches will trigger the build. -#trigger: -#- staging -#- master - -pool: - name: ForecastingBP - vmImage: 'forecastingtestmachine' - -steps: - -- bash: | - echo "##vso[task.prependpath]/data/anaconda/bin" - displayName: Add conda to PATH - -- bash: | - . /anaconda/etc/profile.d/conda.sh && \ - conda activate forecasting_base && \ - Rscript tests/unit/source_entire.R -m "not notebooks and not spark and not gpu" --junitxml=reports/test-unit.xml && \ - conda deactivate - displayName: 'Run R unit tests' - -- task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-unitttest.xml' - testRunTitle: 'Test results for R Unit Tests' \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 494a9eb4..4de6a82f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + import os import pytest from fclib.common.utils import git_repo_path diff --git a/tests/integration/test_notebooks_python.py b/tests/integration/test_notebooks_python.py index 98441373..ffff7c1d 100644 --- a/tests/integration/test_notebooks_python.py +++ b/tests/integration/test_notebooks_python.py @@ -1,5 +1,5 @@ # Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. +# Licensed under the MIT License. import os import pytest diff --git a/tests/pytest.ini b/tests/pytest.ini index 1a95c6d0..501fa424 100644 --- a/tests/pytest.ini +++ b/tests/pytest.ini @@ -1,4 +1,4 @@ [pytest] markers = notebooks - integration \ No newline at end of file + integration