Skip to main content

Introduction

Welcome to the SAP HANA Python Client API for machine learning algorithms. This API enables Python data scientists to access SAP HANA data and build machine learning models using that data directly in SAP HANA.

Overview

The SAP HANA Python Client API for machine learning algorithms provides a set of client-side Python functions for accessing and querying SAP HANA data, and a set of functions for developing machine learning models.

The Python Client API for Machine Learning consists of two main parts:

  • A set of machine learning APIs for different algorithms.

  • The SAP HANA DataFrame, which provides a set of methods for analyzing data in SAP HANA without bringing the data to the client.

This set of APIs is composed of two packages:

  • PAL package

  • APL package

The Predictive Analysis Library (PAL) package consists of a set of Python algorithms and functions which provide access to the machine learning capabilities in SAP HANA. The PAL Python functions cover a variety of different machine learning algorithms for training a model and then the trained model is used for scoring. For details on which specific algorithms are available in this release, please refer to the documentation.

The 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.

This Python library uses the SAP HANA Python driver (hdbcli) to connect to and access SAP HANA.

Getting Started

Install via

>>> pip install hana-ml

Quick Start

  • For HANA tenant databases, use the port number 3NN13 (where NN is the SAP instance number - e.g. 30013).

  • For HANA system databases in a multitenant system, the port number is 3NN13.

  • For HANA single-tenant databases, the port number is 3NN15.

    >>> from hana_ml import dataframe
    >>> conn = dataframe.ConnectionContext( address="<hostname>", port=3<NN>MM, user="<username>", password="<password>")

Return a DataFrame referenced to SAP HANA table.

>>> df = conn.table('MY_TABLE', schema='MY_SCHEMA').filter('COL3>5').select('COL1', 'COL2')

Return a DataFrame from select statement.

>>> df = dataframe.DataFrame(conn, 'select * from MY_SCHEMA.MY_TABLE')

Convert to pandas DataFrame.

>>> pandas_df = df.collect()

Convert to HANA DataFrame from pandas DataFrame.

>>> df = dataframe.create_dataframe_from_pandas(conn, pandas_df, 'MY_TABLE', force=True)

Call SAP HANA Machine Learning Algorithms.

>>> rfc = RandomForestClassifier(n_estimators=3,
                                 max_features=3,
                                 random_state=2,
                                 split_threshold=0.00001,
                                 calculate_oob=True,
                                 min_samples_leaf=1,
                                 thread_ratio=1.0)
>>> rfc.fit(data=df, features=['OUTLOOK', 'TEMP', 'HUMIDITY', 'WINDY'],
         label='LABEL')
>>> rfc.feature_importances_.collect()
  VARIABLE_NAME  IMPORTANCE
0       OUTLOOK    0.449550
1          TEMP    0.216216
2      HUMIDITY    0.208108
3         WINDY    0.126126
>>> result = rfc.predict(data=df2, key='ID', verbose=False)
>>> result.collect()
   ID SCORE  CONFIDENCE
0   0  Play    0.666667
1   1  Play    0.666667

Help

See the [SAP HANA ML API Reference] (https://help.sap.com/doc/1d0ebfe5e8dd44d09606814d83308d4b/2.0.05/en-US/hana_ml.html) for details about developing with the SAP HANA ML API.

License

The SAP HANA ML API is provided via the [SAP Developer License Agreement] (https://tools.hana.ondemand.com/developer-license-3_1.txt).

By using this software, you agree that the following text is incorporated into the terms of the Developer Agreement:

If you are an existing SAP customer for On Premise software, your use of this current software is also covered by the
terms of your software license agreement with SAP, including the Use Rights, the current version of which can be found at:
`https://www.sap.com/about/agreements/product-use-and-support-terms.html?tag=agreements:product-use-support-terms/on-premise-software/software-use-rights <https://www.sap.com/about/agreements/product-use-and-support-terms.html?tag=agreements:product-use-support-terms/on-premise-software/software-use-rights>`_

Metadata

Release files for hana-ml 2.5.20062609

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for hana-ml 2.5.20062609
File Interpreter ABI Platform Actions
hana_ml-2.5.20062609-py3-none-any.whl Python 3 none any Details for hana_ml-2.5.20062609-py3-none-any.whl

Release files / hana_ml-2.5.20062609-py3-none-any.whl

Download URL hana_ml-2.5.20062609-py3-none-any.whl
Size 451.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1563839610fcd6b11a535ed72a511a1dee93cd1a729228a28100539c2a5883a
BLAKE2b-256 checksum
How to use checksums
de9b1a785162eae3b47ad6dd597b7ef663ebf4d3ce8a542dfa72b646e4660577
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.5.3

Security for hana-ml 2.5.20062609

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.5.20062609 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page