When SAP meets Machine Learning

A Price Predictor powered by SAP AI Core

In the past year, Artificial Intelligence has taken the world by storm, and SAP is also fully committed to these new developments. In previous blogs, we have talked about ChatGPT and SAP’s HANA Cloud Vector Engine. This time we are taking a look at SAP AI Core, a service on SAP’s Business Technology Platform (BTP) that offers a powerful AI runtime, which can be integrated with your SAP cloud infrastructure out-of-the-box.

SAP AI Services on BTP

The image below shows an overview of the SAP AI Foundation toolkit, which was introduced at SAP TechEd 2023. It also gives a good idea of all the different AI components that SAP is currently working on. The AI Foundation toolkit offers developers a wide range of AI- and generative AI-powered extensions and applications on SAP BTP. The SAP AI Core service is part of the AI Workload Management offering for instance. This offering consists of tools necessary for the creation and training of (new) models.

Services for AI Developers on SAP BTP

What is SAP AI Core?

The SAP AI Core service is meant to be utilized together with the AI API and the SAP AI Launchpad. An overview of these three components can be seen in the diagram below. The AI Launchpad is an interface that can be used to manage a number of AI runtimes. The AI API provides a standardized way of managing AI scenarios; even scenarios which are not provided on SAP technology.

Architecture Overview

Key features of the SAP AI Core service include the execution of pipelines to preprocess or train your models, the deployment of trained Machine Learning models as a web service and the management of Machine Learning artifacts and workflows. It can also easily be integrated with your cloud infrastructures; you can synchronize your code from your Git repository, register your object store and expose your AI content as a service on the SAP BTP marketplace.


Unfortunately, SAP AI Core is not available in the trial version of SAP BTP. If you want to play around with the service, an Enterprise SAP BTP account is required. You can try out the SAP AI Core service by choosing the free tier service plan. The free tier has a couple of limitations: for example, you are limited to one instance per Global account and one execution or deployment running at a given time.

For the standard service plan, a fixed price is charged every month for every subaccount. Use of resources is charged using adaptable pricing according to the resource type used. The standard service plan is intended for productive usage.

Building a House Price Predictor

So what can we actually do with this service? We are going to build a House Price Predictor by following a tutorial from the SAP Development Center. The goal of this price predictor is to estimate the price of a house in California by training the model on a reference dataset.

Take a look at the Python code in the image below. Firstly, we import a dataset (in this case: a public California Housing dataset). The dataset is then split into a training dataset and a test dataset. The training dataset is used to train the model, while the test dataset is used to evaluate the performance of the model. In other words; can the model make a successful prediction of the house prices in the test set after the training stage is over?

Example Python code for house price prediction

This particular model being used in this example is a Decision Tree Regressor, which is a relatively simple Machine Learning Model. With this model, the data is classified using the available variables. An example of a decision tree can be seen in the image below.

Example of a simple decision tree for job offers

Executing the model

After writing the code, we still need to execute it somehow. This requires quite a lot of different steps. First, we transform our AI code into a Docker image and upload the image to the cloud. Next up, we need to reference our Docker image in our AI workflow. This can be done by creating a YAML file in our repository, which contains the Docker image information.

Creating a YAML file in the repository

We also need to set up our SAP AI Launchpad. In the AI Launchpad, we add an AI API connection to our SAP AI Core instance by providing the appropriate information from our service key. We also need to store our Docker credentials in SAP AI Core and add our Git repository.

Adding the AI API connection

After connecting our AI Core instance to the SAP AI Launchpad, we need to create a new configuration for the AI workflow. During this step, we need to specify the name of the workflow executable that we defined in the YAML file.

Setting up a new configuration

The workflow can be executed after finishing the configuration. When the execution has completed, we can have a look at the execution log to see the result of our test data (this is the print statement at the bottom of our Python code).

Execution results of our code

We can see that our model had an R2-score of 0.579, which implies that the model explains a significant amount of the variance in the data. As such, it can be considered a somewhat accurate model for house price prediction in California.


The SAP AI Core service, when combined with the SAP AI Launchpad and AI API, can provide a comprehensive structure for setting up an AI runtime. However, it is not particularly accessible for first time users. It requires quite a bit of setup (e.g. SAP AI Launchpad and Docker) with many different steps. It is also not available in the trial version of SAP BTP. After setting up the initial configuration though, it can definitely be a useful service.

A full tutorial (which also contains steps for ingesting live data and model comparison) can be found on developers.sap.com: https://developers.sap.com/group.ai-core-get-started-basics.html

We at INNOV8iON will continue to monitor this technology and its developments. Feel free to contact us if you have any further questions on this topic!

Schrijf je in voor onze nieuwsbrief

En blijf op de hoogte van de nieuwste evenementen