Skip to Content
Technical Articles
Author's profile photo Marc DANIAU

Forecasting Intermittent Time Series with Automated Predictive (APL)

Starting with version 2203 of the Automated Predictive Library (APL) intermittent time series are given a special treatment. When the target value has many zeros, typically when the demand for a product or a service is sporadic, APL will no longer put in competition various forecasting models, but it will systematically use the Single Exponential Smoothing (SES) technique.

Let’s take the following monthly quantity as an example.

from hana_ml import dataframe as hd
conn = hd.ConnectionContext(userkey='MLMDA_KEY')
series_in = conn.table('MONTHLY_SALES', schema='APL_SAMPLES')

We run a fit and predict:

from hana_ml.algorithms.apl.time_series import AutoTimeSeries
apl_model = AutoTimeSeries(time_column_name= 'Date', target= 'Qty_Sold', horizon=4, 
                           variable_value_types ={'Date': 'continuous', 'Qty_Sold': 'continuous'})
series_out = apl_model.fit_predict(data = series_in, build_report=True)

We preview the output series:

df =[0:5]).collect()
dict = {'ACTUAL': 'Actual', 
        'PREDICTED_1': 'Forecast', 
        'LOWER_INT_95PCT': 'Lower Limit', 
        'UPPER_INT_95PCT': 'Upper Limit' }
df.rename(columns=dict, inplace=True)

We check that our time series model is indeed based on Simple Exponential Smoothing:

d = apl_model.get_model_components()

Since HANA ML 2.16, we can obtain detail information on the forecasting model from a single report:



APL 2203 uses Single Exponential Smoothing not only for intermittent series. SES is a common technique to model time series that show no trend and no seasonality, like this quarterly series:

series_in = conn.table('SUPPLY_DEMAND', schema='APL_SAMPLES')
from hana_ml.algorithms.apl.time_series import AutoTimeSeries
apl_model = AutoTimeSeries(time_column_name= 'Date', target= 'Demand_per_capita', horizon=4)
series_out = apl_model.fit_predict(data = series_in, build_report=True)

As you may have already noticed in the previous example, SES produces a flat forecast.

The report with its different tabs can be saved as HTML:



To know more about APL

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.