O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running the ets function iteratively over all of the categories

Now that we have run an ets model on one category, we can construct some code to automate model construction over all of the categories.

In the process, we will also save some of the accuracy measures so that we can see how our models performed:

  1. First, sort the dataframe by category, and then by year.

  2. Then, initialize a new dataframe (onestep.df) that we will use to store the accuracy results for each moving window prediction of test and training data.

  3. Then, process each of the groups, all of which have 14 time periods, as an iteration in a for loop.

  4. For each iteration, extract a test and training dataframe.

  5. Fit a simple exponential smoothed model for the training dataset. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required