How it works...

In step 1, we checked the datatype of the column whose values are to be forecasted; here, we used the Sales column. We changed its datatype to numeric. In step 2, we converted the input data into stationary data. This is done to get rid of time-dependent components in the data. We saw that our input data has an increasing trend. In time series forecasting, it is advised to get rid of the trend component before building the model. These trends can be added back to the forecasted values later so that we can get our predictions in the original scale. In this example, we removed the trend by differencing the data with an order of 1; that is, we subtracted the previous observation from the current one.

While using algorithms such ...

Get Deep Learning with R Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.