Skip to main content

Testing decision strategies

4 Tasks

30 mins

Pega Platform
Visible to: All users
Beginner Pega Platform English

Scenario

A decision strategy that produces the next-best-label Action is set up in the application. The purpose of the decision strategy is to select the label with the lowest printing cost. To implement these requirements, the strategy:

  • Considers four labels from the Enablement business issue and Labels group.
  • Computes the printing cost of each label using the following formula: PrintingCost = BaseCost + 5 * Lettercount.
  • Selects only labels with a printing cost that is lower than the average printing cost.
  • Uses a Decision table to apply the following business rules:
    • The Black Label is available for anyone over the age of 18.
    • The Yellow Label is available for anyone over the age of 27 and has a customer lifetime value (CLV) that is under 500.
    • The Red Label is available for anyone over the age of 27 and with a CLV that is over 500.
  • Uses an adaptive model to predict the likelihood of accepting a given label. The propensity is 0.5 for all labels because the adaptive model is not yet trained.
  • Outputs the label with the highest priority, where Priority = Propensity / PrintingCost * 100.

Your task as a System Architect is to confirm that the output is the next best label and correct the strategy if the output indicates otherwise.

Use the following credentials to log in to the exercise system:

Role User name Password
System Architect SystemArchitect rules

Your assignment consists of the following tasks:

Task 1: Save the NextBestLabel strategy in ExerciseArtifacts ruleset and test the strategy with a Data Transform

Save the NextBestLabel strategy in ExerciseArtifacts ruleset, and test the strategy by using the UseCase1 Data Transform.

Name

Age

CLV

UseCase1

28

400

Confirm that the Strategy Result is not the expected next best label. You can find the printing cost of each label in the following table:

Name

Printing Cost

Blue Label

85

Red Label

70

Black Label

60

Yellow Label

70

Tip: The strategy is expected to maximize the Priority = Propensity / Printing Cost * 100 expression. The expected result is the Yellow Label, because it has the lowest printing cost and the propensity to accept is 0.5 for all labels.

Task 2: Identify the cause of the incorrect result and resolve the problem

Select individual strategy components to identify the cause of the incorrect result, and then resolve the problem.

Task 3: Test the NextBestLabel strategy by using a second Data Transform

Create the Usecase2 Data Transform, and then run the strategy to get the Red Label as result. Can you explain why?

Name

Age

CLV

UseCase2

50

600

Tip: In contrast to Usecase1, the CLV value of Usecase2 complies with the Red Label business rule but not with the Yellow Label business rule. The Red Label is selected over the Black Label based on rank.

Task 4: Test the NextBestLabel strategy by using a batch test run

Test the NextBestLabel strategy with a batch test run functionality. Analyze the decisions and performance of the strategy.

 

You must initiate your own Pega instance to complete this Challenge.

Initialization may take up to 5 minutes so please be patient.

Challenge Walkthrough

Detailed Tasks

1 Save the NextBestLabel strategy in ExerciseArtifacts ruleset and test the strategy with a Data Transform

  1. On the exercise system landing page, click Launch Pega Infinity™ to log in to Dev Studio
  2. Log in as a system architect:
    1. In the User name field, enter SystemArchitect.
    2. In the Password field, enter rules.
  3. In the navigation pane of Dev Studio, click Records > Decision > Strategy to open the Strategy landing page.
    dev studio menu navigation
  4. On the Strategy landing page, double-click NextBestLabel to open the strategy canvas.
    select strategy
  5. In the upper-right corner, click Save as.
  6. in the Add to ruleset field, confirm that ExerciseArtifacts 01-01-01 is selected, and click Create and open.
  7. On the strategy canvas, expand the Test pane.
    expand the test pane
  8. On the canvas, double-click to adjust the view.
  9. In the Test run pane, on the Single case tab, expand the Settings section.
  10. In the Settings section, in the Data transform field, click the empty field, press the down arrow, and select UseCase1.
  11. To the right of the Data transform field, click the Open icon to edit the UseCase1 Data Transform to observe the values.
    data transform
  12. Close the Data Transform to return to the strategy.
  13. On the Test run pane, click Save & Run.
    save and run
  14. On the canvas, click the Results component, and then in the results pane, confirm that the NextBestLabel strategy is incorrect.
    Note: The result is incorrect because both the Black Label and the Yellow label Actions follow the business rules. The printing cost of the Black Label is lower than that of the Yellow Label, and the propensity to accept is 0.5 for both labels.
    yellow label end result

2 Identify the cause of the incorrect result and resolve the problem

  1. On the canvas, open the properties dialog box for the Set Printing Cost component, and then confirm that the PrintingCost Action is set in the Define action, target, and source section.
  2. Close the Set Printing Cost component.
  3. On the canvas, select the Average Printing Cost group by component.
  4. In the results pane, confirm that the AverageCost of the four propositions is computed and available.
    Note: The results contain only a single page because the Group by component combines all Actions in a single row.
    average cost 1
  1. On the canvas, select the Below Average filter component, and then confirm that the component contains three Actions. Check which Action is missing.
    below average 1
  2. In the results pane, check that the remaining Actions have a PrintingCost that is lower than the AverageCost, which is referenced from the Group by component.
  3. On the canvas, confirm that AverageCost is not propagated by the filter component and is only referenced.
  4. On the canvas, right-click the Business Rules component, and then select open the Decision Table and evaluate the result for RedLabel for the current case.
    Note: What do you expect the result to be, Stop or Proceed? The segment of the RedLabel is Stop as it is inapplicable to Usecase1.
    decision table 2
  1. Close the decision table.
  2. On the canvas, select the Business Rules component, and then, in the result pane, confirm that a Segment output is available and properly computed for all three labels.
    table results
  3. On the canvas, select the Segment Proceed filter component, and then, in the results pane, confirm that this Action is filtered out and that the component contains the remaining two Actions.
  4. On the canvas, select the Propensity to Accept component, and then, in the results pane, confirm that a Propensity value is generated for both Actions.
    Note: The Adaptive model is not yet trained, so the propensity is 0.5 for both Actions.
  1. On the canvas, right-click the Set Priority component, and then select Properties.
  2. In the Source field, click the Gear icon to open the Expression builder.
    1. In the Expression builder, click the Test tab.
    2. On the Test tab, in the pyPropensity field, enter 0.5
    3. In the PrintingCost field, enter 70.
    4. Click outside the field, and then confirm that the Result is 0.71428571428571428600.
      PrintingCost result
    5. Optional: Test the formula with other values for the propensity and the printing cost.
      Note: Notice that a high priority is correlated with a low printing cost and a high propensity to accept.
    6. Click Cancel to close the Expression builder.
  3. Close the Set property properties dialog box to return to the strategy canvas.
  4. On the canvas, select the Set Priority component, and then, in the results pane, confirm that the LabelPriority values of the two Action are 0.71 and 0.83 in the Results section.
  5. On the canvas, select the Best Label component, and then, in the results pane, confirm that the component outputs the Yellow Label with a 0.71 priority instead of the Black Label with a 0.83 priority.
  6. Open the properties of the Best Label component, and then confirm that the component currently selects the Top 1 label, which is correct, and that it incorrectly ranks the labels with a low priority first.
    lowest priority
  7. Select Highest first, and then click Submit to correct the ranking order.
    highest priority
  8. On the canvas, expand the Test run pane, and then click Save & Run to view the results of the test.
  9. Confirm that the result of the NextBestLabel strategy is the BlackLabel, which is the correct result.
    correct result 2

3 Test the NextBestLabel strategy by using a second Data Transform

  1. In the Test run pane, in the Data transform field, click the Open icon to open the Data Transform.
  2. In the header of the Data Transform, click Save as to configure the Data Transform record.
    save as
  3. In the Label field, rename the Data Transform to UseCase2.
  4. In case there is a Development branch, ensure that No branch is selected.
  5. Click Create and open to create the Data Transform.
  6. In the Source column of the .Age target enter 50.
  7. In the Source column of the .CLV target, enter 600.
    usecase 2
  8. In the upper-right, click Check in, and enter the appropriate comment.
  9. Click Check in, and then close the Data Transform.
  10. Close the UseCase1 Data Transform and navigate back to the Next Best Label strategy.
  11. In the Test run pane, in the Data transform field, enter or select UseCase2, and then click Save & Run.
  12. Notice the result of the NextBestLabel strategy for UseCase2 and explain the results.
    Tip: Both the Black Label and the Red Label are applicable. The strategy selects the Black Label because it has the lowest printing cost.

4 Test the NextBestLabel strategy by using a batch test run

  1. In the Test run pane, in the Data transform field, click the Batch tab to open the batch testing panel.
  2. Click Settings to configure the batch test run.
    1. In the Batch settings window, in the Input data field, select Customer.
    2. Click Run to start the batch test run.
      batch test run settings 3
  3. Click the Filter component to avoid prioritization in the strategy and observe the results of the batch test run. The strategy chooses Black Label as the next best label for 98.6%, Yellow Label for the 57.9%, and the Red Label for the 28.8% of the population.
  4. Click Settings to configure a new test run.
    1. In the Batch settings window, click Performance to test the strategy run time.
    2. In the Data set field, enter or select Customer, and then click Run to start.
  5. Observe the results.
    strategy performance test 2
  6. In the Show canvas results for field, select Time spent, and observe the results. Click each component of the strategy to display the component-specific information.

This Challenge is to practice what you learned in the following Module:


Available in the following missions:

If you are having problems with your training, please review the Pega Academy Support FAQs.

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 Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice