7 forecasting techniques you’ll never use, but should know them anyway | by Mahbubul Alam | Towards Data Science

The time series forecasting toolbox is like the Swiss army knife — many options to choose from. These options often leave data scientists overwhelmed, puzzled, and sometimes outright confused.
Last time I checked, there are at least 25 different techniques. But fortunately, they are really not much different from one another. For example, the ARIMA techniques (e.g. AR, MA, ARIMA, SARIMA, ARIMAX) appear different, but in reality one is just a variation of another.
Today, however, I’m going to write about some simple techniques that people rarely talk about yet extremely useful to understand forecasting basics. These models are known as “benchmark” or “baseline” forecasting.
As you will see below, these techniques are rarely applied in practice, but they help build forecasting intuition upon which to add additional layers of complexity. First I’ll demo some codes as examples, then talk about their similarities and differences in the latter part of the article.
Let’s first implement three techniques: Naive, Mean and Drift models. The dataset I am using for the demo is the air passenger dataset with only one variable. And of course I’ll be using python!
Import libraries and data
import pandas as pdimport matplotlib.pyplot as pltimport numpy as npdf = pd.read_csv("../gasprice.csv")
Split data into training and testing sets
train = df.iloc[0:556, ]test = df.iloc[556:,]yhat = test.copy().drop('value', axis=1)
Modeling
# model buildingyhat['naive'] = train.loc[len(train)-1, 'value'] #Naiveyhat['average'] = train['value'].mean() #Averageyhat['drift'] = train.loc[len(train)-1]['value'] +  (train.loc[len(train)-1]['value'] - train.loc[0]['value'])/len(train)* np.linspace(0, len(yhat)-1, len(yhat)) # Drift# visualizationplt.figure(figsize=(12,4))plt.plot(train['value'], label = "train")plt.plot(test['value'], label = "test")plt.plot(yhat['naive'], label = "naive")plt.plot(yhat['average'], label = "mean")plt.plot(yhat['drift'], label = "drift")plt.legend()plt.show()
Evaluation
# model evaluationeval = pd.concat([test, yhat], axis = 1)eval['error_naive'] = eval['value'] - eval['naive']mae_naive = np.mean(np.abs(eval['error_naive']))rmse_naive = np.sqrt(np.mean(eval['error_naive']**2))print('MAE_naive:', round(mae_naive))print('RMSE_naive:', round(rmse_naive))eval = pd.concat([test, yhat], axis = 1)eval['error_average'] = eval['value'] - eval['average']mae_average = np.mean(np.abs(eval['error_average']))rmse_average = np.sqrt(np.mean(eval['error_average']**2))print('MAE_average:', round(mae_average))print('RMSE_average:', round(rmse_average))eval = pd.concat([test, yhat], axis = 1)eval['error_drift'] = eval['value'] - eval['drift']mae_drift = np.mean(np.abs(eval['error_drift']))rmse_drift = np.sqrt(np.mean(eval['error_drift']**2))print('MAE_drift:', round(mae_drift))print('RMSE_drift:', round(rmse_drift))
MAE_naive: 16
RMSE_naive: 20
MAE_average: 25
RMSE_average: 28
MAE_drift: 17
RMSE_drift: 21
Now let’s get into some details to understand basics.
Naive Forecast:
Naive Forecast:
In Naive forecast the future value is assumed to be equal to the past value. So the sales volume of a particular product on Wednesday would be similar to Tuesday’s sales.
Naive forecast acts much like a null hypothesis against which to compare an alternative hypothesis — sales revenue will be different tomorrow because of such and such reasons.
2. Seasonal Naive:
Seasonal naive, as the name suggests, factors in seasonality in its forecast. So in a way, it’s an improvement over Naive method. In this case, the revenue forecast for December would be equal to the revenue in the previous year’s December. This is done to factor in holiday effects.
Again, it still works like a null hypothesis but considers seasonality as its key improvement over Naive forecast.
3. Mean Model
Naive forecast takes one past value and uses it as a predicted value. Mean model, in contrast, takes all the past observations, makes an average, and uses this average as the forecast value.
If data is randomly distributed, without clear patterns and trends (also known as the white noise), a mean model works as a better benchmark than a naive model.
4. Drift model
Drift model is yet another variation of Naive forecast, but with an obvious improvement. As in Naive, it takes the last observation, then adjusts the observation based on variation in past values.
Forecast value = past observation +/- average change in past observations
5. Linear Trend
Mean model described above is a horizontal, constant line that doesn’t change over time because it works on training data without a trend. However, if a trend is detected, a linear model provides a better forecast value than a Mean model.
Forecasting using Linear Trend in practice is actually the line of best fit (i.e. regression line) of the following form:
Y(t) = alpha + beta*t
An RSME or R2 value determines how good the fitted line is for prediction.
6. Random Walk
In this case the forecast value “walks” a random step ahead from its current position (similar to Brownian Motion). Like a walking toddler, the next step can be in any random direction but isn’t too far from where the last step was.
Y(t+1)=Y(t) + noise(t)
The stock price on Wednesday will likely be close to Tuesday’s closing price, so a Random Walk provides a reasonable guestimate. But it’s not suitable to predict too many time-steps ahead, because, well, each step is random.
7. Geometric Random Walk
In Geometric Random Walk, the forecast for the next value will be equal to the last value plus a constant change (e.g. a percentage monthly increase in revenue).
Ŷ(t) = Y(t-1) + α
It’s also called the “random-walk-with-growth model”. Stock prices in the long-term follow somewhat a Geometric Random Walk model.
The purpose of this article was to unearth some non-typical time series forecasting techniques. Even though they are not used in practice, they are an essential stepping-stone to build intuition for how forecasting works and how to develop advanced forecasting models.
Additional articles are in the pipeline on some advanced forecasting techniques, so stay tuned. For news and updates, you can find/follow me on Twitter.