Skip to Content
Previous

Predictive Analytics Using Application Function Modeler

By Adrian Plata

This tutorial series will cover a pair of sample projects utilizing the predictive analytics capabilities of SAP HANA, express edition. This tutorial will show you how to use a Application Function Modeler to access the predictive analytics library.

You will learn

How to use the Predictive Analysis Library through SAP HANA Studio.

Details

This tutorial creates the same models as the previous tutorial by only using template modules within SAP HANA Studio. For more tutorials on using Predictive Analysis Library, see the SAP HANA Academy YouTube Playlist.


Step 1: Open the SAP HANA Development Perspective

In your SAP HANA Studio window, hover over Window -> Perspective -> Open Perspective. Select SAP HANA Development if is available, otherwise, click Other…. From the drop down list, select SAP HANA Development.

SAP HANA Development Perspective

The SAP HANA Development perspective opens.

Step 2: Create a New Repository Workspace

Through the Repositories tab, right-click on your user login for your tenant database and select Create Repository Workspace.

Create A New Repository

The Create New Repository Workspace window opens.

Make sure your user login for your tenant database is selected. You may use your default workspace, or untick the Use Default Workspace box and create a new workspace by filling in Workspace Name and Workspace Root. By default, these locations are the same as the home repository you select when starting Eclipse and SAP HANA Studio.

Create A New Repository

Click Finish to create your new workspace.

Step 3: Create a New Repository Package

Right-click on your new repository workspace and select New -> Repository Package.

Create Repository Package

The Create Repository Package window opens.

Give your package a name and click Finish to create the package.

Create Repository Package
Step 4: Create a Flowgraph Model

Right-click on your new package and select New -> Other….

New Other

The New window opens.

Scroll down to SAP HANA -> Database Development -> Flowgraph Model. Click Next >.

Select Flowgraph Model

The New Flowgraph Model window opens.

Ensure that your new package is highlighted. Give your flowgraph a name. Ensure that Flowgraph for Activation as Stored Procedure is selected. Click Finish.

Note:
SAP HANA Studio will automatically add .hdbflowgraph to your file name.

Name Flowgraph

Your new flowgraph opens.

Step 5: Arrange the Flowgraph

Under the Predictive Analysis Library window, select Time Series Analysis, scroll down and drag and drop Auto ARIMA onto your flowgraph.

Auto ARIMA

Under the General window, drag and drop Data Source onto your flowgraph.

Data Source

The Choose a Table or a View window opens. For this example, search for and select the STOCKS (PAL) table. Click OK.

Select Stocks

Hover over the STOCKS block. Click and hold the Connect icon Connect from Data_2 and drag over to Data under the Auto ARIMA block.

Drag Data to Data_2

Under the General window, drag and drop Data Sink (Template Table) onto your flowgraph.

Drag Data Sink

Hover over the AUTOARIMA block. Click and hold the Connect icon Connect from RESULT and drag over to DATA_3 under the TEMPLATESINK block.

Arranged Flowgraph
Step 6: Adjust Model Properties

To view the results you will need to change the RESULT and TEMPLATESINK properties. Hover over RESULT under AUTOARIMA. Click the Properties icon Properties.

RESULT Properties

The Properties window opens. Click Signature. Change VALUE Length to 5000.

RESULT Properties

Change the TEMPLATESINK properties. Hover over TEMPLATESINK and click the Properties icon Properties.

TEMPLATESINK Properties

Under the Properties window, add your user schema to Authoring Schema. Add a name for Catalog Object. You may also check the Truncate Table box.

TEMPLATESINK Properties
Step 7: Create the Model

Change the properties of the flowgraph. Right-click on the white space and select Properties.

Flowgraph Properties

By Target Schema, add your user schema.

Flowgraph Target Schema

Click the Activate icon Activate. A new job will appear in your Job Log.

Click the Execute icon Execute.

Note:
If you receive an error during this step, see the troubleshooting section below.

Optional: Preview the Model

Return to the SAP HANA Administration Console perspective. Under your user login to your tenant database, cascade down from Catalog -> User -> Tables. Right-click on Catalog_Object and click Open Data Preview.

Note:
The Catalog Object is named earlier in this tutorial.

Catalog Object Preview

You may notice that this data is identical to Step 2: Run the Model SQL Script in the previous tutorial.

Step 8: Prepare the Model for Analysis

Return to your flowgraph.

Under the Predictive Analysis Library window, select Time Series Analysis and scroll down and drag and drop ARIMA (Forecast) onto your flowgraph.

Drag ARIMA (Forecast)

Hover over the AUTOARIMA block. Click and hold the Connect icon Connect from RESULT and drag over to INPUT under the ARIMAFORECAST block.

Change the PARAMS_2 by hovering over it and clicking the Properties icon Properties. Under the Fixed Content tab, change the INTARGS to 200.

Change PARAMS_2
Step 9: Prepare the New Flowgraph Blocks

Under the General window, drag and drop another Data Sink (Template Table) onto your flowgraph.

Hover over the ARIMAFORECAST block. Click and hold the Connect icon Connect from OUTPUT and drag over to DATA_4 under the new TEMPLATESINK_2 block.

As before, change the TEMPLATESINK properties. Hover over TEMPLATESINK_2 and click the Properties icon Properties. Under the Properties window, add your user schema to Authoring Schema. Add a name to Catalog Object. You may also check the Truncate Table box.

Edit TemplateSink_2 Properties

Click the Activate icon Activate. A new job will appear in your Job Log.

Step 10: Preview the Data

Click the Execute icon Execute.

Go to the Systems tab. Refresh your tenant database. Find the results table under your user login. Go to Catalog -> User -> Tables -> Second_Catalog_Object. Right-click on the table and select Open Data Preview.

Catalog Object 2 Preview

You will notice that this data is identical to Step 4: Run the Predict SQL Script in the previous tutorial.

Troubleshooting: Unsupported encoding Cp 1252

When you Activate your Auto ARIMA model, you may encounter this error:

Unsupported Encoding Error

To fix this error, open the Problems window. Go to Window -> Show View -> Other…. From there, go to General and select Problems. Click OK.

Problems

You will see the error in the log. Right-click the error and click Quick Fix. The Quick Fix window opens.

Quick Fix Window

Click Finish. A message explaining the fix will appear.

Quick Fix Message

Click OK.

Click the Activate icon Activate and continue with the tutorial.

Next Steps

Updated 12/12/2017

Time to Complete

20 Min

Beginner

Tags

Prerequisites

Next Steps

Next
Back to top