LinkedIn
Copied!

Table of Contents

Configuring a data transform for a JSON output mapping

Version:

Only available versions of this content are shown in the dropdown

Support a machine learning service connection to external topic models by converting the JSON response from the prediction endpoint to a format that Pega Platform accepts.

The output mapping is based on the structure of the Data-NLP-Outcome class.

  1. In the header of Dev Studio, click Create Data Model Data Transform .

  2. In the Label field, enter a short description for your data transform.

  3. In the Additional configuration options section, select Clipboard.

  4. In the Context section, specify the context for your data transform:

    1. In the Apply to field, enter Data-NLP-ExternalMapping.

    2. In the Add to ruleset field, select the name of a ruleset to contain the record, and then select the version number from the list.

  5. Click Create and open.

  6. On the Definition tab, map the properties in the Data-NLP-Outcome class to the paths in the JSON response.

    Use the following actions, target properties, and source properties for the mapping:

    Choices Actions
    Specify an array in the JSON response Use the Append and Map to action to map the .pxResults target property to a path in the JSON response as the source. Enter the path in a format that follows the JSON Pointer specification but without a slash (/) prefix.

    If you leave the Source field empty, the mapping will point to the following JSON path: /

    Specify a path in the JSON response Use the Set action to map the .pySource_jsonPath target property to a path in the JSON response as the source. Enter the path in a format that follows the JSON Pointer specification but without a slash (/) prefix.

    Examples:

    • classification/score
    • displayName
    Specify a property in the Data-NLP-Outcome class Use the Set action to map the .pyDestination_property target property to a property in the Property in the Data-NLP-Outcome class as the source.

    Examples:

    • .pyTopics
    • .pyName
    • .pyConfidenceScore
    Enter the path in a format that follows the JSON Pointer specification but without a slash (/) prefix. For more information, see JSON Pointer specification and Configuring a data transform.

    The following code represents a sample JSON response from a prediction endpoint:

    {
      "payload": [
        {
          "annotationSpecId": "2348805326557413376",
          "classification": {
            "score": 0.9609469
          },
          "displayName": "greeting"
        },
        {
          "annotationSpecId": "42962317343719424",
          "classification": {
            "score": 0.026214128
          },
          "displayName": "thanks"
        }
      ]
    }

    To convert the properties from the JSON response to a format that Pega Platform accepts, a data transform is used, as in the following figure:

    Data transform for a sample JSON response
    dt-ml-service-example icon

    The sample JSON response contains the classification/score and displayName properties in a JSON array property payload.

    The data transform maps the classification/score and displayName properties to the Pega Platform .pyConfidenceScore and .pyName properties, and the JSON array payload property to .pyTopics.

    The property .pxResults indicates each node in the JSON array that includes child properties that need to be processed.

  7. Click Save.

Complete configuring the machine learning service connection by defining the new data transform as the output mapping. For more information, see Configuring a machine learning service connection for topic models using REST API.

Related Content

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.