Skip to Content

Get Next-Item Recommendations Based on Users' Browsing History

Use the Personalized Recommendation service to give visitors to your website next-item recommendations based on their browsing history.
You will learn
  • How to call and test the Personalized Recommendation service
  • How to access and use Swagger UI (User Interface)
  • How to submit a training job and trigger model serving
  • How to get recommendations based on users’ browsing history
Juliana-MoraisJuliana MoraisSeptember 26, 2022
Created by
Juliana-Morais
July 14, 2022
Contributors
Juliana-Morais
Priya-Ghodke

The Personalized Recommendation service uses state-of-the-art machine learning techniques to give visitors to your website highly personalized recommendations based on their browsing history and/or item description. Train and use machine learning models to deliver these recommendations across a wide range of business scenarios. With Personalized Recommendation, you can elevate user experience and engagement, enhance item discovery and conversion, retain business control, curate relevance, and meet key performance indicators.

To try out the Personalized Recommendation service, the first step is to upload data that will be used to train a machine learning model. For more information, see Personalized Recommendation SAP Help Portal documentation. For further definition of specific terms, see Concepts. See also Free Tier Option Technical Constraints.

In this tutorial, you will use a dataset that contains users’ browsing history to train a machine learning model to get next-item recommendations based on an item that has been recently clicked by a visitor to your website.

  • Step 1

    You will use Swagger UI, via any web browser, to call the Personalized Recommendation service APIs. Swagger UI allows developers to effortlessly interact and try out every single operation an API exposes for easy consumption. For more information, see Swagger UI.

    In the service key you created for Personalized Recommendation in the previous tutorial: Use the Free Tier Service Plan to Set Up Account for Personalized Recommendation and Get Service Key, you should find (outside the uaa section of the service key) an entry called url (as highlighted in the image below).

    1. To access the Personalized Recommendation Swagger UI, add /doc to the url value, paste it into any web browser and press Enter.

      PRS
    2. To be able to use the Swagger UI endpoints, you need to authorize yourself. In the top right corner, click Authorize.

      PRS
    3. Get the access_token value created in the previous tutorial: Get OAuth Access Token for Personalized Recommendation via Web Browser, then add Bearer in front of it, and enter in the Value field.

      Bearer <access_token>
      
      PRS
    4. Click Authorize and then click Close.

      PRS

    Choose the correct value that needs to be entered when authorizing the Swagger UI for the Personalized Recommendation service.

  • Step 2

    Use the POST /standard/rs/v1/tenants/{tenant}/jobs/file-upload endpoint to upload data and trigger the machine learning model training job.

    1. Click the endpoint name to expand it.

    2. Click Try it out.

      PRS
    3. Enter tenant name. It is required to enter a name of your choice for tenants. You can use, for example, pr_tutorial.

    4. Click on data to download the training data ZIP file. Click Choose File to upload the training data.

    5. Enter site name. Same as tenant name, but if you leave the field blank, it will be named automatically as default. You can use, for example, pr_tutorial_site.

      PRS
    6. Set serve_model to true for automatic deployment of real-time model serving instance. To trigger the machine learning training, click Execute.

      PRS

      You should receive a response like the following:

      PRS
  • Step 3

    Use the GET /standard/rs/v1/tenants/{tenant}/jobs/latest endpoint to check the status of the ongoing training job.

    1. Click the endpoint name to expand it.

    2. Click Try it out.

    3. Enter tenant name (pr_tutorial) and site name (pr_tutorial_site). Click Execute.

    PRS

    You should receive a response like the following:

    PRS

    After a few minutes, the training job status should change to SUCCEEDED.

    PRS
  • Step 4

    Use the GET /standard/rs/v1/tenants/{tenant}/servings endpoint to check the deployment status for model serving.

    1. Click the endpoint name to expand it.

    2. Click Try it out.

    3. Enter site name (pr_tutorial_site) and tenant name (pr_tutorial). Click Execute.

    PRS

    You should receive a response like the following:

    PRS

    After a few minutes, the serving job status should change from PENDING to SUCCEEDED.

    PRS
  • Step 5

    There are four different choices of inference calls as you can see in Inference Options. For this tutorial, we will use Next-Item Recommendations.

    Use the POST /standard/rs/v1/tenants/{tenant}/recommendations/next-items endpoint to get next-item recommendations.

    1. Click the endpoint name to expand it.

    2. Click Try it out.

    3. In the payload, you can enter the following (that means the user has recently clicked an item with itemID 2858):

      JSON
      Copy
      {
         "items_ls":[
            "2858"
         ]
      }
      
    4. Enter site name (pr_tutorial_site) and tenant name (pr_tutorial). Click Execute.

    PRS

    You should receive a response like the following:

    PRS

    The response shows a sequence of recommendations based on the user’s past clickstreams. Since we included in the payload the itemID “2858” as our past clickstream, the model is able to recommend 10 other items related to the itemID “2858”.

    You have now successfully used the Personalized Recommendation service to get recommendations based on users’ browsing history.

Back to top