3.4.3 Build Model
To build a model using the time series data, use the Exponential Smoothing algorithm on the OML proxy object ESM_SH_DATA generated during the exploratory stage.
Oracle provides the Exponential Smoothing algorithm for time series.
Exponential smoothing is a forecasting method for time series data. It is a moving average method where exponentially decreasing weights are assigned to past observations. Components of Exponential Smoothing Model (ESM) such as trend and seasonality extensions, can have an additive or multiplicative form. For additive forms, the amplitude of the variation is independent of the level, whereas for multiplicative forms, the variation is connected to the level. The simpler additive models assume that error or noise, trend, and seasonality are linear effects within the recursive formulation.
To build a model using a supervised learning algorithm you may use a subset of the data into training and test data. Time series models usually use historical data to predict the future. This is different from model validation for classification and regression, which normally involves splitting data randomly into training and test sets. In this use case, there is no need to split the data set because the model is always predicting the current value based on information from the past. This means that although it seems that you train and test on the same data set, but when the model is applied, the forecast is always based on the previous date. In this use case, you will use the oml proxy object ESM_SH_DATA.
- To get help on the Exponential Smoothing Model (ESM), run the following
script:
help(oml.esm)
- Create a Holt-Winters Model using quarterly setting
To build the model using the
ESM_SH_DATA
proxy object, run the following statement:try: oml.drop(model = 'ESM_SALES_FORECAST_1') except: pass setting = {'EXSM_INTERVAL':'EXSM_INTERVAL_QTR', # accumulation interval = quarter 'EXSM_PREDICTION_STEP': '4', # prediction step = 4 quarters 'EXSM_MODEL': 'EXSM_WINTERS', # ESM model = Holt-Winters 'EXSM_SEASONALITY': '4', # seasonal cycle = 4 quarters 'EXSM_SETMISSING': 'EXSM_MISS_AUTO'} # treat missing values as an irregular time series train_x=ESM_SH_DATA[:,0] train_y=ESM_SH_DATA[:,1] esm_mod = oml.esm(**setting).fit(train_x, train_y, time_seq = 'TIME_ID')
Examine the script:
EXSM_INTERVAL
: Specifies the interval of the data set or a unit of interval size, like day, week, month, etc. This setting applies only to the time column with datetime type. For example, if you want to predict for quarterly sales, the setting isEXSM_INTERVAL_QTR
.EXSM_PREDICTION_STEP
: Specifies how many predictions to make. For example, if you want to display each value representing a quarter, then a value of 4 gives four values (Quarters) prediction into the future.EXSM_MODEL
: Specifies the type of exponential smoothing model to be used. As an example, EXSM_WINTERS represents the Holt-Winters triple exponential smoothing model with additive trend and multiplicative seasonality. This type of model considers various combinations of additive and multiplicative trend, seasonality and error, with and without trend damping.EXSM_SEASONALITY
: Specifies how long a season lasts. The parameter specifies a positive integer value as the length of seasonal cycle. The value it takes must be larger than 1. For example, 4 means that every group of four values forms a seasonal cycle, which makes sense if you are using 4 quarters to represent a year.EXSM_SETMISSING
: Specifies how to handle missing values. In time series, the special value EXSM_MISS_AUTO indicates that, if the series contains missing values it is to be treated as an irregular time series.
This completes the model building stage.
Parent topic: Time Series Use Case