Setting Up the Environment

Objectives

After completing this lesson, you will be able to:
  • Identify the two main components of the Python ML client
  • Define the core features of SAP HANA Cloud
  • Configure the SAP HANA Cloud environment

What is the Python ML Client for SAP HANA?

The Python machine learning client for SAP HANA (hana-ml) is a Python package that enables data scientists to access SAP HANA data. Practitioners can build machine learning models using the data directly in SAP HANA [2].

The Python machine learning client for SAP HANA consists of two main components:

  • SAP HANA DataFrame, which provides a set of methods for accessing and querying data in SAP HANA without bringing the data to the client.
  • A set of machine learning APIs for developing machine learning models.

The machine learning APIs are composed of two packages:

PAL package

PAL package consists of a set of Python algorithms and functions which provides access to machine learning capabilities in the SAP HANA Predictive Analysis Library (PAL). SAP HANA PAL functions cover a variety of machine learning algorithms for training a model and then the trained model is used for scoring.

APL package

Automated Predictive Library (APL) package exposes the data mining capabilities of the automated analytics engine in SAP HANA through a set of functions. These functions develop a predictive modeling process that analysts can use to answer simple questions on their customer datasets stored in SAP HANA.

HANA-ML uses the SAP HANA Python driver (hdbcli) to connect to and access SAP HANA. For further information, please refer to [2].

What is SAP HANA Cloud?

SAP HANA Cloud is a multi-model database management system that empowers the architects of the future to build and deploy the next generation of intelligent data applications at scale [3].

SAP HANA supports a comprehensive environment for machine learning. On the server side, it offers embedded machine learning libraries as well as capabilities for integrating common machine learning tools. On the client side, its machine learning APIs can be used to directly develop embedded machine learning models in SAP HANA [4].

References

[1] California Housing dataset

[2] Python ML Client for SAP HANA

[3] SAP HANA Cloud

[4]SAP HANA Machine Learning Overview

Environment Setup and Preparation

Technical prerequisites

  • Instance of SAP HANA Cloud with ScriptServer (APL, PAL enabled)
  • Python hana-ml package 2.21.24062800, and other packages and dependencies installed

Python packages for SAP HANA

The following cell loads and imports diverse modules. As you may know, a module can be considered to be the same as a code library.

Python
123456
#import hana database client for Python from hdbcli import dbapi #import hana-ml package import hana_ml print (hana_ml.__version__)

Output:

2.20.24042601

Python
123456
#importing other packages used import pandas as pd import matplotlib.pyplot as plt import time import numpy as np import os

SAP HANA Cloud database connection

With the Python machine learning client for SAP HANA (hana-ml), connections are always related to a SAP HANA DataFrame. Further, for SAP HANA Cloud, an encrypted connection is required.

Learners should have the SAP HANA system address, and the credentials to access it because they need to be provided to instantiate the class hana_ml.dataframe.ConnectionContext; it represents a connection to a SAP HANA database instance [1].

Python
1234567
from hana_ml import dataframe address = "b8xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.hana.prod-eu10.hanacloud.ondemand.com" port = 443 user = 'XX_XXXX' conn = dataframe.ConnectionContext(address, port, user, encrypt=True, sslValidateCertificate=False)

References

[1] SAP class hana_ml.dataframe.ConnectionContext

Log in to track your progress & complete quizzes