Skip to Content

Series Data services on the API Business Hub

Previous

Series Data services on the API Business Hub

By Abdel DADOUCHE

Discover how to test SAP Leonardo Machine Learning Foundation service on the SAP API Business Hub

Details

You will learn

In this tutorial, you will learn where to find and test the SAP Leonardo Machine Learning Functional Services published on the SAP API Business Hub that consumes series data content.

The Time Series Change Point Detection API Machine Learning Functional Services will be used as an example to demonstrate how to consume series data content, but you will be able to transpose this tutorial to other services which also consume content like :

  • the Time Series Forecast API

The Time Series Change Point Detection service allows you to calculates and returns the probability of the change point for each data point in the provided univariate or multivariate time series.

Step 1: Search the SAP API Business Hub

In order to consume the Time Series Changepoint Detection API SAP Leonardo Machine Learning Foundation service, you will first need to get the service URI, request and response parameters.

Go to https://api.sap.com/.

SAP API Business Hub

Then you will be able to search for the SAP Leonardo Machine Learning - Functional Services, then click on the package found.

SAP API Business Hub

Select Time Series Changepoint Detection API.

SAP API Business Hub

You can also access the page directly from the following address:

Please log in to access this content.
Step 2: Analyze the service

As you can notice the API has only one resource (or service): /inference_sync.

Now click on the /inference_sync link to expand the section.

Note: the term inference refers to the application phase (scoring) an existing model (as opposed to the training or inception phase) and sync for synchronous.

As stated in the description, the service accepts either:

  • an archive file with a zip/tar extensions containing multiple text files
  • a text file
  • a text as input representing the series of data

The service returns a list of change point probabilities.

The supported text file formats is plain text only.

The input text, file, files or archive file will be sent as a FormData query parameter in the service request.

A series of options are also required for the following parameters:

  • separator: Values separator (the default value is the comma: “,”)
  • series_separator: Series separator for multivariate time series. (the default value is the colon: “:”)
Please log in to access this content.
Step 3: Test the service

In the top right corner of the page, click on the Log On button.

You will be prompted for your SAP Cloud Platform credentials.

Scroll down to the Parameters section.

In the options field enter the following:

{"separator" : "|"}

In the texts field enter the following series data (a Cosine series):

93969.262|76604.444|50000.000|17364.818|-17364.818|-50000.000|-76604.444|-93969.262|-100000.000|-93969.262|-76604.444|-50000.000|-17364.818|17364.818|50000.000|76604.444|93969.262|100000.000

Now, scroll down and click on Try out.

Please take a note of the Request URL which we will use later:

In the Response Body, you will get the input data along with the probability of a change point for the corresponding value in the given time series.

You will notice that we provided 20 input values, and received only 19. This is because the probability is computed for each data point interval.

For example, the probability that a change point has been detected between the first and second element of the series (93969.26208 & 76604.44431) is 6.8%.

{
  "_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "processed_time": "Wed, 02 Aug 2017 08:41:04 GMT",
  "request": {
    "files": null,
    "options": {
      "separator": "|",
      "series_separator": "#"
    },
    "tenantName": "imgclassif-tech-user",
    "texts": [
      "93969.26208|76604.44431|50000|17364.81777|-17364.81777|-50000|-76604.44431|-93969.26208|-100000|-93969.26208|-76604.44431|-50000|-17364.81777|17364.81777|50000|76604.44431|93969.26208|100000"
    ]
  },
  "response": [
    "0.068,0.190,0.318,0.450,0.418,0.202,0.106,0.066,0.056,0.074,0.192,0.378,0.484,0.354,0.230,0.114,0.056,nan"
  ],
  "status": "DONE",
  "tenantName": "imgclassif-tech-user"
}

Note: The result you will obtain might be slightly different form the one displayed above.

Please log in to access this content.
Step 4: Test the service for multivariate series

In the context of this service, the term “multivariate” represent the ability to execute the service for multiple series of data in one request.

In the options field enter the following:

{"separator" : "|" , "series_separator" : "#"}

In the texts field enter the following series data (a Cosine series and a Sinus series):

93969.262|76604.444|50000.000|17364.818|-17364.818|-50000.000|-76604.444|-93969.262|-100000.000|-93969.262|-76604.444|-50000.000|-17364.818|17364.818|50000.000|76604.444|93969.262|100000.000#34202.014|64278.761|86602.540|98480.775|98480.775|86602.540|64278.761|34202.014|0.000|-34202.014|-64278.761|-86602.540|-98480.775|-98480.775|-86602.540|-64278.761|-34202.014|0.000

Note: each series must have the same length.

In the Response Body, you will get the input data along with the probability of a change point for the corresponding value in the given time series.

You will notice that we provided 2 series 20 input values, and received only 19. This is because the probability is computed between each series data point.

For example, the probability that a change point has been detected between the first element of both series (93969.26208 & 34202.014) is 5.8%.

{
  "_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "processed_time": "Wed, 02 Aug 2017 08:34:45 GMT",
  "request": {
    "files": null,
    "options": {
      "separator": "|",
      "series_separator": "#"
    },
    "tenantName": "imgclassif-tech-user",
    "texts": [
      "93969.262|76604.444|50000.000|17364.818|-17364.818|-50000.000|-76604.444|-93969.262|-100000.000|-93969.262|-76604.444|-50000.000|-17364.818|17364.818|50000.000|76604.444|93969.262|100000.000#34202.014|64278.761|86602.540|98480.775|98480.775|86602.540|64278.761|34202.014|0.000|-34202.014|-64278.761|-86602.540|-98480.775|-98480.775|-86602.540|-64278.761|-34202.014|0.000"
    ]
  },
  "response": [
    "0.058,0.220,0.316,0.396,0.242,0.274,0.386,0.266,0.278,0.346,0.326,0.312,0.244,0.312,0.462,0.190,0.034,nan"
  ],
  "status": "DONE",
  "tenantName": "imgclassif-tech-user"
}
Please log in to access this content.
Step 5: Validation

Provide an answer to the question below then click on Validate.

Based on the provided documentation, what is the name of the series separator option?
×

Optional

Step 6: Investigate similar services

You can also try the following Machine Learning Functional Services consuming text content:

  • the Time Series Forecast API

For more information, you can also check the online SAP Leonardo Machine Learning Foundation documentation

Please log in to access this content.

Next Steps

Updated 06/01/2018

Time to Complete

10 Min

Beginner

Next Steps

Next
Back to top