pdstools.utils.pega_outcomes

Pega standard outcome domain knowledge.

Provides channel-aware defaults for outcome label resolution, based on Pega CDH standard outcomes documentation. Designed for use by any pdstools component that maps raw Pega outcome strings to business metrics.

The Impact Analyzer uses this for Impressions/Accepts per Channel/Direction. The IH class uses it for per-channel Engagement labels and direction-aware OpenRate applicability.

Attributes

Functions

resolve_outcome_labels(→ dict[str, dict[str, list[str]]])

Resolve explicit per-channel outcome label mappings from data.

get_channel_defaults(→ dict[str, list[str]])

Return the unfiltered Pega standard outcome defaults for a channel.

get_openrate_labels(→ dict[str, list[str]] | None)

Return OpenRate outcome labels if applicable for this channel.

Module Contents

_CHANNEL_OUTCOME_DEFAULTS: dict[str, tuple[list[str], list[str]]]
_DEFAULT_IMPRESSIONS: list[str] = ['Impression']
_DEFAULT_ACCEPTS: list[str] = ['Click', 'Clicked']
resolve_outcome_labels(channels_with_outcomes: dict[str, list[str]]) dict[str, dict[str, list[str]]]

Resolve explicit per-channel outcome label mappings from data.

For each channel, looks up Pega standard outcome defaults by matching the channel prefix (the part before ‘/’), then filters to only outcome values actually present in the data. Channels not in the defaults table fall back to the global digital-channel defaults.

Parameters:

channels_with_outcomes (dict[str, list[str]]) – Mapping of channel (Channel/Direction format) to the distinct outcome strings present in the data for that channel.

Returns:

Per-channel mapping of the form:

{
    "Web/Inbound": {"Impressions": ["Impression"], "Accepts": ["Clicked"]},
    "Call Center/Inbound": {"Impressions": ["Impression"], "Accepts": ["Accepted"]},
}

Only outcome values present in the data are included.

Return type:

dict[str, dict[str, list[str]]]

Examples

>>> resolve_outcome_labels({"Web/Inbound": ["Impression", "Clicked", "Rejected"]})
{'Web/Inbound': {'Impressions': ['Impression'], 'Accepts': ['Clicked']}}
>>> resolve_outcome_labels({"Call Center/Inbound": ["Impression", "Accepted"]})
{'Call Center/Inbound': {'Impressions': ['Impression'], 'Accepts': ['Accepted']}}
get_channel_defaults(channel: str) dict[str, list[str]]

Return the unfiltered Pega standard outcome defaults for a channel.

Looks up the channel prefix (part before ‘/’) in the defaults table. Returns all candidate outcome values regardless of what is in the data.

Parameters:

channel (str) – Channel in “Channel/Direction” format (e.g. “Web/Inbound”).

Returns:

{"Impressions": [...], "Accepts": [...]} with all standard candidate values for this channel type.

Return type:

dict[str, list[str]]

_OPENRATE_POSITIVE: list[str] = ['Opened', 'Open']
_OPENRATE_NEGATIVE: list[str] = ['Impression', 'Pending']
get_openrate_labels(channel: str) dict[str, list[str]] | None

Return OpenRate outcome labels if applicable for this channel.

OpenRate (whether a pushed message was opened) only applies to outbound channels. Returns None for inbound channels or channels without a direction component.

Parameters:

channel (str) – Channel in “Channel/Direction” format (e.g. “Email/Outbound”).

Returns:

{"positive": [...], "negative": [...]} for outbound channels, None for inbound or unknown direction.

Return type:

dict[str, list[str]] or None