Running models with test data

As you build decision models, task models, and predictive models, you can verify that they produce the results you expect by running them with test data.

About this task

The run feature allows you to apply data to the decision logic that is defined in your model to make sure that it works as expected.

When you test a model, you define and run test data to validate specific scenarios. You can provide the data in a friendly form or in its underlying JSON format.

Warning: You cannot run models that contain errors.

Procedure

  1. Open a model, and click the Run tab.
  2. Optional: If you are testing a task model, select a function to choose the ruleflow that you want to run.
  3. Click Add test data set.
    Note: You can easily rename and delete data sets using the Rename test data set Edit details button and Delete test data set Delete button buttons in the top bar.
  4. Select data items from the generated form to add them to the data set and enter values for each item. If you prefer to edit the content of the data set in JSON, use the content switcher to open the rich JSON editor Content switcher button.

    In decision and predictive models, you can click the icon at the top of the data set to learn more about supported data formats.

  5. Click Run to run the model with the data set.

Results

The run report is displayed in the results pane. The content of this report varies slightly depending on the type of model.

Table 1. Run report details for decision and predictive models
Section Description
Decision output Displays the output of each end decision. For each decision node, the report shows its name and the JSON output it produced.
Messages Displays printed messages that are extracted from the run history, useful for debugging and understanding the execution flow.
Run history Provides detailed information for all nodes in the decision or predictive model, traced from end decisions back to start nodes:
Decision nodes
Shows the node name, number of executed rules, interaction policy, and output. You can click the arrow icon next to the node name to view details on the executed rules.
Input data nodes
Shows the node name and output.

Clicking any node name or rule name takes you to the node or the rule.

Statistics Displays execution metrics such as compilation time and execution time.

You can also click Show JSON output to view all input, output, and execution data in a single JSON structure. The JSON output is organized into four main sections: payload, infos, statistics, and messages. payload corresponds to the Decision output section, and infos corresponds to the Run history section.

Table 2. Run report details for task models
Tab Description
Decision output Displays the final output of the task model in JSON format.
Messages Displays printed messages that are extracted from the run history, useful for debugging and understanding the execution flow.
Run history Provides a detailed execution trace of the task model. The trace includes:
  • The full execution hierarchy across the ruleflow, tasks, and rules
  • Input and output data at each step of execution
  • Execution metrics
  • Details about executed and skipped rules
  • Printed messages captured during execution
  • Any recorded exceptions
Statistics Displays execution metrics such as compilation time and execution time.

Example

Open the Approval decision model available in the Loan Approval decision service in the Banking sample, and click the Run tab. You can see data sets that correspond to different test scenarios. When you run the Mr Doe loan data set, the loan is approved and you get the following result:

{
    "approved" : true,
    "message" : "Congratulations! Your loan has been approved"
}

In this data set, look for the Yearly income field and change its value from 100000 to 80000. When you run the data set with this new value, the loan is not approved and you get the following result:

{
    "approved" : false,
    "message" : "Too big Debt/Income ratio: 0.45597806940658686"
}

This result validates that the yearly income of the borrower influences the approval of the loan. The number of months during which the borrower repays the loan is also supposed to influence this approval. If you change the value of the number of monthly payments from 72 to 120 and run this data, the loan is now approved again:

{
    "approved" : true,
    "message" : "Congratulations! Your loan has been approved"
}

This result validates that the number of monthly payments influences the approval of the loan, and that it can compensate for a yearly income that might be too low.