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: 
AndreasForster
Product and Topic Expert
Product and Topic Expert
The Automated Mode of SAP Predictive Analytics allows the efficient creation of powerful predictive models. Installing the Automated Predictive Library (APL) on SAP HANA makes it possible to train these models directly in SAP HANA. The data does not have to be extracted into an external system, the architecture is simplified and agility is increased.

In the official documentation you will find the overall steps of the installation process of the APL. This blog shows how to apply these steps, from downloading the APL to using it in SAP Predictive Analytics.

This blog was initially written in January 2018 for SAP Predictive Analytics 3.3, APL3 and SAP HANA Express 2.0 SPS02. In 2019 a new Python interface was released for the APL. This "SAP HANA Python Client API for Machine Learning Algorithms" (also known as hana_ml) requires APL4, for which the installation steps are slightly different. These differences are mentioned in the APL4 section at the bottom of this blog.

Prerequisites


It is assumed that you have a SAP HANA Express 2.0 up and running. You have also been able to establish a connection from the SAP HANA studio. (Please note that the APL is also available for SAP HANA 1, but this article is focussing on SAP HANA 2.0)

In case you do not have such a system available yet, you can follow the SAP HANA Express documentation. To follow the steps in this blog it is sufficient to download the "Server only virtual machine". Some of the steps listed below are flagged for "Server + Applications VM Only", these are not required to be able to install the APL:

You should be seeing something similar to this screen. Notice that the only installed plug-in is the Application Function Library (AFL). If the APL was installed, we should see it there.



 

Download the APL


The APL can be downloaded from the Software center. You find it by following this path:

  • INSTALLATIONS & UPGRADES

  • By Alphabetical Index

  • P

  • SAP Predictive Analytics

  • SAP PREDICTIVE ANALYTICS 3

  • COMPRISED SOFTWARE COMPONENT VERSIONS

  • PRED ANALYTICS APL 3 FOR HANA2


Before downloading, make sure to set the drop down on that page to the correct operating system. The APL has different downloads for x86 and PowerPC.

Then download the latest version, currently: "APL 3.3. PRED ANALYTICS APL 3.3 FOR HANA2". The file itself is called SAPPAAPL3003_0-80002689.TGZ.


Copy the APL onto SAP HANA


The file you have just downloaded needs to be copied onto the SAP HANA system. I am using a program called WinSCP, but plenty of other options are available.

Connect from WinSCP to the SAP HANA operating system, logging on with the 'hxeadm' user and the password you had specified during the setup of SAP HANA Express.



Copy the APL you had downloaded into the /tmp folder on the SAP HANA system.



 

Once the file is copied, it needs to be extracted. Still in WinSCP, select the file on the right hand side, on the SAP HANA system. Right-click the file, select "File Custom Commands", then "UnTar/GZip...". Confirm all prompts and the file is extracted into a newly created folder.

Install APL


The actual installation of the APL can be started from within the SAP HANA Administration Console. Right-click on your System connection, choose "Lifecycle Management", then "Platform Lifecycle Management" and finally "SAP HANA Platform Lifecycle Management".



 

You will be prompted for a password. Logon with the hxeadm user of the Linux operating system. This logon is NOT for your SAP HANA user.



 

Click into "Install or Update Additional Components". Go into "Add Software Locations..." and choose the "installer" folder of the extracted APL file.



 

Confirm the selection with "Add". You should see a screen that the "Automated Predictive Library" has been detected in that folder. Continue with "Next". Confirm that you want to install this library.



 

On the next screen enter the passwords for both the Linux operating system user as well as for your SAP HANA user. Continue and the install will start and complete in a few minutes.



 

The APL is now installed! It will show as new plugin on the Administration panel of the SAP HANA Administration Console. If this screen was open during the install, you need to close and reopen it to see the new component.



 

 

Configure APL


The APL is installed, but not quite ready yet for use. It still needs to be configured. We will configure the system so that we can use the APL on the HXE tenant database, which comes with SAP HANA Express 2.0.

To run the APL the script server needs to be activated for the database. Open an SQL Console for the SYSTEMDB under the SYSTEM user and execute this statement:
ALTER DATABASE HXE ADD 'scriptserver';

 

Now make sure you have a connection to HXE in the SAP HANA Administration Console. Just specify the tenant database "HXE" when adding the system.



 

Let's create a user, under which we call the APL. I name the user SAPPA. Grant this user the role APL_EXECUTE.



 

The role can also be assigned to an existing user, ie with this SQL statement:
call _SYS_REPO.GRANT_ACTIVATED_ROLE ('sap.pa.apl.base.roles::APL_EXECUTE','SAPPA');

 

Test APL


The APL is installed and configured. As final step we should verify everything is working well. The second line in the following SQL syntax has to be called by the user that wants to call the APL The first line switched the code execution to that user. Stating the obvious, you need to replace the Xs with the user's real password.
CONNECT SAPPA PASSWORD XXXXXXXXX;
call "SAP_PA_APL"."sap.pa.apl.base::PING"(?)

Only if the above statement executes successfully, the APL is ready!

 

Bonus Material


If you just wanted to install the APL, then you are all set. Should you want to see how SAP Predictive Analytics leverages that APL, then read on. With SAP Predictive Analytics you get a graphical interface to train predictive models, without the need of using SQL.

This final part of the blog is kept rather short, it is assuming you are already fairly familiar with SAP HANA and SAP Predictive Analytics. Since the user is interacting with SAP HANA, ie to upload data, the user has been granted additional rights. To help you test this quickly, you could assign all roles visible in the SAP HANA Administration Console to the user.

On the machine you have SAP Predictive Analytics installed, you have to create a 64 bit ODBC source to SAP HANA Express. This uses the HANA ODBC driver that is installed by the SAP HANA Client, which is part of the SAP HANA Express download. In the ODBC Administrator, the driver is called HDBODBC.

The Server:Port setting for you is probably something like: hxehost:39015



 

To connect directly to HXE, you can go into "Settings" and add a property called DATABASENAME, pointing to the HXE database.



 

We also need some data in SAP HANA Express to train a model. You can use your own data or test with sample data of SAP Predictive Analytics. There are many ways to upload data. For such a quick test I prefer to use SAP Predictive Analytics itself. Make sour your installation of SAP Predictive Analytics has the same version as the APL you installed. Open the tool and in the menu select "Toolkit", followed by "Perform a Data Transfer".

This options allows to easily move data. You can transfer all columns from that file through ODBC into SAP HANA:
C:\Program Files\SAP Predictive Analytics\Desktop\Automated\Samples\Census\Census01.csv

Stay in SAP Predictive Analytics to train a model. Go into "Create a Classification/Regression Model". Select the ODBC source and choose the table that holds the data from the Census file.
Set the "class" column as target variable. Exclude the columns KxIndex and fnlwgt.

Start the model training and the status messages should show the term "APL". The model is being trained directly within SAP HANA, without extracting the data!



 

APL4


This blog was initially written in January 2018 for SAP Predictive Analytics 3.3, APL3 and SAP HANA Express 2.0 SPS02. In 2019 a new Python interface was released for the APL. This "SAP HANA Python Client API for Machine Learning Algorithms" (also known as hana_ml) requires APL4, for which the installation steps are slightly different.

The APL4 can be downloaded from the Software center. You find it by following this path:

  • SUPPORT PACKAGES & PATCHES

  • By Alphabetical Index

  • H

  • SAP HANA PLATFORM EDITION

  • SAP HANA PLATFORM EDITION 2.0

  • APL 4 FOR HANA 2 SP03+

  • SUPPORT PACKAGE PATCHES

  • [Select your operating system, ie LINUX ON X86_64 64BIT]


The current version of the file as of November 2019 is SAPPAAPL4_1910_0-80004547.ZIP (Predi. Analy. APL 1910 for SAP HANA 2.0 SPS03 and beyond).

When downloading SAP HANA Express 2.0 SPS04 you have the option to also download an older version of APL4. This file is currently (November 2019) not on the version required by hana_ml. Hence you still need to download the most recent version from the Software center as described above.

Do not unzip the APL4 file on Windows. Transfer the file onto the SAP HANA operating system (ie using WinSCP as described above. Then extract the file directly on the Linux system, ie with the command unzip SAPPAAPL4_1910_0-80004547.zip.

With these few adjustments you should be able to follow this blog to install APL4 for use with the hana_ml wrapper.
9 Comments