hana_ml.artifacts package ========================= The artifacts package consists of the following sections: * :ref:`generators_abap-label` * :ref:`deployers-label` * :ref:`generators_hana-label` hana_ml.artifacts.generators.abap and hana_ml.artifacts.deployers.amdp modules provide 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 create a AMDPDeployer to upload such class into the ISLM framework by creating 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**. Apart of the standard developer authorizations, you need to get the **SAP_INTNW_ISLM** role for deployers related functions. 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. Then, you can now take the generated code in the 'outputdir' and deploy it to SAP S/4HANA with ISLM. All you need is to provide the .abap file, and some basic parameters for the ISLM registration. >>> deployer = AMDPDeployer(backend_url=backend_url, backend_auth=(backend_user, backend_password), frontend_url=frontend_url, frontend_auth=(frontend_user, frontend_password)) >>> guid = deployer.deploy(fp="XXX.abap", model_name="MODEL_01", catalog="$TMP", scenario_name="DEMO_CUSTOM01", scenario_description="Hello S/4 demo!", scenario_type="CLASSIFICATION", force_overwrite=True, master_system="ER9", transport_request="$TMP", sap_client='000') After the deployment is competed, you can see an intelligent scenario in the 'Intelligent Scenarios' Fiori app of the ISLM framework. This scenario has a name specified during the deployment step. .. _deployers-label: hana_ml.artifacts.deployers.amdp -------------------------------- .. automodule:: hana_ml.artifacts.deployers.amdp :members: :inherited-members: :show-inheritance: :exclude-members: publish_islm, train_islm, delete_islm .. _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