Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Configuring a data transform for a JSON output mapping

Updated on July 5, 2022

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 CreateData ModelData 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:

    ChoicesActions
    Specify an array in the JSON responseUse 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.
    Note:

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

    Specify a path in the JSON responseUse 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/scoredisplayName
    Specify a property in the Data-NLP-Outcome classUse 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.
    For example:

    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
    Data transform record showing the output mapping for the sample JSON response

    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.
What to do next: 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.
  • Previous topic Configuring a machine learning service connection for topic models using REST API
  • Next topic Creating a text categorization model to run topic models through an API

Have a question? Get answers now.

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

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us