hana_ml.artifacts package ========================= The artifacts package consists of the following sections: * :ref:`generators_abap-label` * :ref:`generators_hana-label` The hana_ml.artifacts.generators.abap module provides various methods which helps you to embed machine learning algorithms of SAP HANA (e.g. Predictive Analysis Library (PAL)) via the Python API into SAP S/4HANA business applications with Intelligent Scenario Lifecycle Management (ISLM) framework. The ISLM framework is integrated into the ABAP layer (SAP Basis) so that the intelligent scenarios from above layers in SAP S/4HANA stack can utilize the framework completely. Specifically, a custom ABAP Managed Database Procedure (AMDP) class for a machine learning model needs to be created which can be consumed by ISLM. Suppose you have a machine learning model developed in hana-ml and decide to embed it into a SAP S/4HANA business application. First, you can create an AMDPGenerator to establish a corresponding AMDP class and then import the generated ABAP class code within your ABAP development environment. Then the ABAP class can be used within an Intelligent Scenario managed by ISLM. Within ISLM, you can perform operations, such as training, activating, and monitoring of the intelligent scenario for a specific SAP S/4HANA. .. note:: SAP S/4HANA System Requirement: **S/4HANA 2020 FPS1 or higher**. Supported hana-ml algorithm for AMDP: **UnifiedClassification**. AMDP Examples ------------- Let's assume we have a connection to SAP HANA called connection_context and a basic Random Decision Trees Classifier 'rfc' with training data 'diabetes_train_valid' and prediction data 'diabetes_test'. Remember that every model has to contain fit and predict logic, therefore the methods `fit()` and `predict()` have to be called at least once. Note that we also need to enable the sql tracer before the training. >>> connection_context.sql_tracer.enable_sql_trace(True) >>> connection_context.sql_tracer.enable_trace_history(True) >>> rfc_params = dict(n_estimators=5, split_threshold=0, max_depth=10) >>> rfc = UnifiedClassification(func="randomdecisiontree", **rfc_params) >>> rfc.fit(diabetes_train_valid, key='ID', label='CLASS', categorical_variable=['CLASS'], partition_method='stratified', stratified_column='CLASS') >>> rfc.predict(diabetes_test.drop(cols=['CLASS']), key="ID") Then, generate abap managed database procedures (AMDP) artifact by creating an AMDPGenerator: >>> generator = AMDPGenerator(project_name="PIMA_DIAB", version="1", connection_context=connection_context, outputdir="out/") >>> generator.generate() The generate() process creates a .abap file on your local machine based on the work that was done previously. This .abap file contains the SQL logic wrapped in AMDPs you have created by interacting with the hana-ml package. .. _generators_abap-label: hana_ml.artifacts.generators.abap --------------------------------- .. automodule:: hana_ml.artifacts.generators.abap :members: :inherited-members: :show-inheritance: .. _generators_hana-label: hana_ml.artifacts.generators.hana --------------------------------- .. automodule:: hana_ml.artifacts.generators.hana :members: :inherited-members: :show-inheritance: :exclude-members: HanaConsumptionProcessor, HanaSDAGenerator, HanaSDAConsumptionProcessor, HanaGeneratorHelper