Analytics Legends The knowledge platform for SAP Analytics
Concept card

hana-ml — Python Machine Learning Inside SAP HANA Cloud

hana-ml — Python Machine Learning Inside SAP HANA Cloud — Analytics Legends section illustration for the SAP Analytics knowledge base (concepts, studies, Academy)

As of 2026-09-25

What is hana-ml?

hana-ml is SAP's official PyPI package ("hana-ml", checked today: version 2.30.26091800) that wraps PAL and APL's in-database procedures behind an estimator-style Python API — ConnectionContext, DataFrame, UnifiedClassification/Regression, GridSearchCV, and ModelStorage, which can even schedule retraining. Data never leaves HANA; the same choice between PAL-style manual tuning and APL-style automation carries over into which submodule you import.

What hana-ml actually is

hana-ml is SAP's official Python client machine-learning library for SAP HANA. The PyPI registry entry, checked directly today, is unambiguous: package name hana-ml, summary "Python Machine Learning Client for SAP HANA", home page sap.com, current release 2.30.26091800 — a date-encoded version number pointing at an 18 September 2026 build, which is itself a useful fact: this library ships on a near-continuous release cadence, not an annual one, so pinning a version in a client's requirements file matters more than it would for a typical stable data-science package.

Mechanically, hana-ml is a Python wrapper around the same AFL procedures PAL (C343) and APL (C344) expose in SQL. It does not implement machine learning in Python; it generates and executes the same in-database calls, then returns results. That's the whole design point: a data scientist gets a familiar, scikit-learn-shaped API while every actual computation still runs inside HANA against tables that never leave the database.

The push-down pattern, seen in real code

SAP's own sample notebooks show the pattern directly. hana_ml.dataframe.ConnectionContext opens the connection to HANA; hana_ml.dataframe.DataFrame wraps a table or a SQL query — calling .head(), .dtypes(), .distinct() or .count() on it runs the operation inside HANA and returns only the result, not the underlying rows. A real SAP sample builds this in four lines: open a ConnectionContext, load training and test partitions with DataSets.load_diabetes_data(connection_context) from hana_ml.algorithms.pal.utility, and the data never crosses into local Python memory as a full table — only summaries and the eventual model output do.

Why it matters

  • hana-ml's version number is date-encoded (2.30.26091800, checked on PyPI today) — this library ships far more often than an annual data-science package, so version pinning and re-testing cadence belong in the project plan, not an afterthought.
  • hana-ml doesn't add new algorithms of its own — it's a Python front door to PAL (C343) and APL (C344); a consultant who treats it as a separate ML library will misjudge what's actually available.
  • ModelStorage's scheduling methods (set_schedule/start_schedule/terminate_schedule) mean retraining orchestration can live inside the same object that saved the model, which changes how an MLOps conversation for a HANA-based model should be scoped versus a typical external ML platform.

Key points

  • hana-ml is SAP's official PyPI package ("hana-ml"), "Python Machine Learning Client for SAP HANA" — checked today at version 2.30.26091800, a date-encoded, near-continuously released version.
  • It's a Python wrapper, not a separate ML engine: hana_ml.algorithms.pal wraps PAL (C343), hana_ml.algorithms.apl wraps APL (C344); all computation runs inside HANA.
  • Push-down pattern: ConnectionContext opens the HANA connection; DataFrame wraps a table/query, and operations like .head()/.dtypes()/.count() execute inside HANA.
  • UnifiedClassification/UnifiedRegression (func parameter selects the underlying algorithm) are the estimator-style entry points; GridSearchCV/RandomSearchCV drive hyperparameter search.
  • ModelStorage saves and versions a model (save_model, list_models) and can schedule retraining directly (set_schedule, start_schedule, terminate_schedule).
  • Installed with plain pip install hana-ml; the HANA side needs PAL/APL (the AFL component) already installed and licensed.
  • SAP's own sample repository (SAP-samples/hana-ml-samples) mirrors the PAL/APL split in its own folder structure — Python-API/pal vs Python-API/apl notebooks.

Terms used on this page

ConnectionContext
hana_ml.dataframe class that opens and manages the connection to a SAP HANA instance.
DataFrame (hana-ml)
A wrapper around a HANA table or SQL query; operations execute inside HANA (push-down), not client-side.
UnifiedClassification / UnifiedRegression
Estimator-style classes wrapping multiple PAL algorithms, selected via a func parameter, with scikit-learn-like fit/predict methods.
ModelStorage
hana_ml class that saves, versions, lists and can schedule retraining of a model stored in HANA tables.
Push-down
The pattern where computation runs inside the database engine against data that never leaves it, rather than pulling rows to the client first.

Sources

  1. PyPI — hana-ml package registry entry (name, version 2.30.26091800, summary), fetched 2026-09-25
  2. SAP-samples/hana-ml-samples — DiabetesUnifiedClassificationHGBT.ipynb (ConnectionContext, DataFrame, UnifiedClassification, GridSearchCV, ModelStorage, set_schedule) — GitHub (SAP), fetched 2026-09-25
  3. SAP-samples/hana-ml-samples — Python-API folder structure (pal vs apl notebooks) — GitHub (SAP), fetched 2026-09-25
  4. SAP-samples/hana-ml-samples — README (project scope, PAL/AFL prerequisite) — GitHub (SAP), fetched 2026-09-25

Full card available to members. What the full card adds: the full decision framework · the common pitfalls and their fix · the cheat sheet · the code blocks · the facts worth quoting.

Open in the app →