Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
marc_daniau
Advisor
Advisor
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')
series_in.head(8).collect()


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 = series_out.select(series_out.columns[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)
df.head(6)


We check that our time series model is indeed based on Simple Exponential Smoothing:
d = apl_model.get_model_components()
list(d.values())[0]


Since HANA ML 2.16, we can obtain detail information on the forecasting model from a single report:
apl_model.generate_notebook_iframe_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)

apl_model.generate_notebook_iframe_report()


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:



apl_model.generate_html_report('My_APL_Report')

 

To know more about APL