This blog is part of a series which is related to setting up Smart Data Streaming, IoT Services & Predictive Services.


HANA Cloud Platform – Using IoT services, SDS & Predictive services


In the previous blog post, I showed the steps involved to setup Predictive services on HANA Cloud Platform. In this blog, I am going to use the Predictive services on top of the IoT sensor table which is accumulating sensor data pushed via HCP IoT services & Smart Data Streaming.

Before proceeding with using the Predictive services on HCP, ensure that the java application “aac4paservices” has the status Started. Launch the application using the URL shown in the Overview menu

You will be directed a HCP Predictive services with two tiles as shown below.

The Administration section will give lot of information related to the APL version and binding info.

The API documentation section will be of great help to all developers. It comes with complete documentation of all the APIs and also provides the option to test the APIs.

The next thing you must be wondering is where we do the actual work with APIs.  This is where a REST client comes into play to test the service. I have used Postman client as it is embed within Chrome and I find it easier to see network traces. Once you have tested the APIs, you can then incorporate it within your HTML5 or java programs.

Apply predictive analysis to sensor table

In the previous blog post, I have used a table called SENSOR01 where all the sensor data from an IoT device is being collected via HCP IoT services & Smart Data Streaming. I don’t have a large data set, but I have got about 408 records to just showcase how the REST APIs work.

As you would have noticed, the table collects temperature and light sensitivity details from a device over a period of time. I am going to use the Outliers service to find if there is an odd value among the dataset which is captured in the above table.

Invoking Outliers API on a Dataset

The first step is to register a dataset which can be used for analysis. In this case, my dataset it the “sensor01” table.

In the REST Client, I have provided the below information

Operation: POST

URLhttps://aac4paservices<accountname>.<HCP landscape>/com.sap.aa.c4pa.services/api/analytics/dataset/sync

Body: { “hanaURL”: “HANAUSER1/SENSOR01”}

Notice that the response comes with ID: 26 which is assigned to this dataset.

To use the Outliers API, change the info as below in the REST client

Operation: POST

URL: https://aac4paservices<accountname>.<HCP Landscape>/com.sap.aa.c4pa.services/api/analytics/outliers/sync

Body:


{
"datasetID": 26,
"targetColumn" : "c_temp",
"numberOfOutliers" : 2




   }

In the datasetID, I provide the value of the dataset obtained earlier and I have specifically indicated to apply the analysis on column “c_temp” which holds temperate data from the IoT device. I have also indicated to show only top 2 outliers.

Below is the response. You can see the output of the Outliers analysis provides with me with the top two temperatures which appear to have deviated from the rest of the data points. This information can be used to further analyse the root cause.

Consuming the REST APIs in WebIDE

I can take this API and now use it within my SAPUI5 application within WebIDE to be able to visualize the analysis in a table format.

I had to create a destination in the HCP cockpit which refers to the below URL

https://aac4paservices<accountname>.<HCP Landscape>/com.sap.aa.c4pa.services/api/analytics

In the neo-app.json file, I added the destinations which can be used in the controller.

Below is how a sample output would look like when I try to view all the outliers provided by the REST APIs.

In this blog I showed how easy it is to enable Predictive services on HCP and use it in your applications. When dealing with streaming data in real time, sometimes, we need to be able to apply such a predictive model on the fly to capture such trends and action on them. This is where the scoring equation service comes handy. You can use scoring equation APIs to build a model which can be applied on streaming data and predict in real time.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Frank Schuler

    Hello Murali,

    thank you for this excellent blog.

    I am trying to consume the HCPps API from a Fiori Overview Page Application, but the Data Connection configuration fails because it requires an $metadata endpoint to inspect the service.

    Is this possible with HCPps? If not, could you share the code of your SAPUI5 application where you display the outliners?

    Very best regards and many thanks in advance

    Frank

    (0) 

Leave a Reply