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
0 Kudos

In HANA ML 2.20, APL introduces a new tab “Local Explanations” in the time series HTML report. This new tab includes a waterfall chart showing how each component of the time series model contributed to individual forecasts. Thanks to this visualization end users will be able to better understand how individual forecasts are generated by the predictive model. This feature requires APL 2325 or a later version.

Let’s create a Jupyter notebook to see how it works.

We will use a daily number of visits for a touristic site. This series has two candidate predictors, Weather and Temperature, that can help improve the forecast accuracy.

We first define the HANA dataframe for the input series:

 

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

 

IMG_01.png

Then we fit the historical data and extrapolate 7 days ahead:

 

from hana_ml.algorithms.apl.time_series import AutoTimeSeries
apl_model = AutoTimeSeries(time_column_name= 'Day', target= 'Visits', 
                           horizon= 7, last_training_time_point='2023-12-17 00:00:00')
series_out = apl_model.fit_predict(data = series_in, build_report=True)
df_out = series_out.collect()

 

Last, we generate the HTML report:

 

apl_model.generate_html_report('my_html')
apl_model.generate_notebook_iframe_report()

 

Here are the 7 values in the horizon presented in a table:

IMG_02.png

The forecasted value for December 19th is: 377. To see how this number is decomposed we go to the Local Explanations tab:

IMG_03.png

The data used to build the waterfall chart comes from the following tabular report:

 

df = apl_model.get_debrief_report('TimeSeries_ForecastBreakdown').deselect('Oid').collect()
df.style.hide(axis='index')

 

IMG_04.png

 

 

 

 

 

 

 

 

 

To know more about APL