pdstools.decision_analyzer.plots

Attributes

Classes

Functions

offer_quality_piecharts(df, propensityTH, ...[, ...])

getTrendChart(df[, stage, return_df, level])

plot_priority_component_distribution(value_data, ...)

Violin + ECDF + summary statistics for a single prioritization component.

plot_component_overview(→ plotly.graph_objects.Figure)

Small-multiples violin panel showing all components side by side.

create_win_distribution_plot(...)

Create a win distribution bar chart with highlighted selected items.

create_parameter_distribution_boxplots(...)

Create box plots comparing parameter distributions between selected actions and others.

Module Contents

class Plot(decision_data)
_decision_data
threshold_deciles(thresholding_on, thresholding_name, return_df=False)
distribution_as_treemap(df: polars.LazyFrame, stage: str, scope_options: list[str])
Parameters:
  • df (polars.LazyFrame)

  • stage (str)

  • scope_options (list[str])

sensitivity(win_rank: int = 1, hide_priority=True, return_df=False, reference_group=None)

If reference_group is None, this works as global sensitivity, otherwise it is local sensitivity where the focus is on the refernce_group.

Parameters:

win_rank (int)

global_winloss_distribution(level, win_rank, return_df=False)
propensity_vs_optionality(stage='Arbitration', df=None, return_df=False)
optionality_funnel(df)
action_variation(stage='Final', return_df=False)
trend_chart(stage: str, scope: str, return_df=False) tuple[plotly.graph_objects.Figure, str | None]
Parameters:
Return type:

tuple[plotly.graph_objects.Figure, str | None]

decision_funnel(scope: str, additional_filters: polars.Expr | list[polars.Expr] | None = None, return_df=False)
Parameters:
  • scope (str)

  • additional_filters (polars.Expr | list[polars.Expr] | None)

filtering_components(stages: list[str], top_n, AvailableNBADStages, additional_filters: polars.Expr | list[polars.Expr] | None = None, return_df=False)
Parameters:
  • stages (list[str])

  • additional_filters (polars.Expr | list[polars.Expr] | None)

distribution(df: polars.LazyFrame, scope: str, breakdown: str, metric: str = 'Decisions', horizontal=False)
Parameters:
  • df (polars.LazyFrame)

  • scope (str)

  • breakdown (str)

  • metric (str)

prio_factor_boxplots(reference: polars.Expr | list[polars.Expr] | None = None, return_df=False) tuple[plotly.graph_objects.Figure, str | None]
Parameters:

reference (polars.Expr | list[polars.Expr] | None)

Return type:

tuple[plotly.graph_objects.Figure, str | None]

rank_boxplot(reference: polars.Expr | list[polars.Expr] | None = None, return_df=False)
Parameters:

reference (polars.Expr | list[polars.Expr] | None)

component_action_impact(top_n: int = 10, scope: str = 'Action', additional_filters: polars.Expr | list[polars.Expr] | None = None, return_df=False)

Horizontal bar chart showing which items each component filters most.

One facet per component (top components by total filtering), bars show items sorted by filtered decision count. The scope controls whether the breakdown is at Issue, Group, or Action level.

Parameters:
  • top_n (int, default 10) – Maximum number of items per component.

  • scope (str, default "Action") – Granularity: "Issue", "Group", or "Action".

  • additional_filters (pl.Expr or list of pl.Expr, optional) – Extra filters applied before aggregation.

  • return_df (bool, default False) – If True, return the DataFrame instead of a figure.

Return type:

go.Figure or pl.DataFrame

component_drilldown(component_name: str, additional_filters: polars.Expr | list[polars.Expr] | None = None, sort_by: str = 'Filtered Decisions', return_df=False)

Bar chart drilling into a single component’s filtered actions with value context.

Shows filtered actions sorted by the chosen metric, with secondary axis for average scoring values when available.

Parameters:
  • component_name (str) – The pxComponentName to drill into.

  • additional_filters (pl.Expr or list of pl.Expr, optional) – Extra filters applied before aggregation.

  • sort_by (str, default "Filtered Decisions") – Column to sort by. Also accepts “avg_Value”, “avg_Priority”.

  • return_df (bool, default False) – If True, return the DataFrame instead of a figure.

Return type:

go.Figure or pl.DataFrame

optionality_per_stage(return_df=False)
optionality_trend(df: polars.LazyFrame, return_df=False)
Parameters:

df (polars.LazyFrame)

offer_quality_piecharts(df: polars.LazyFrame, propensityTH, AvailableNBADStages, return_df=False, level='Stage Group')
Parameters:

df (polars.LazyFrame)

getTrendChart(df: polars.LazyFrame, stage: str = 'Output', return_df=False, level='Stage Group')
Parameters:
  • df (polars.LazyFrame)

  • stage (str)

_ECDF_MAX_ROWS = 50000
plot_priority_component_distribution(value_data: polars.LazyFrame, component: str, granularity: str)

Violin + ECDF + summary statistics for a single prioritization component.

Returns:

violin_fig, ecdf_fig, stats_df

Return type:

tuple of (go.Figure, go.Figure, pl.DataFrame)

Parameters:
  • value_data (polars.LazyFrame)

  • component (str)

  • granularity (str)

plot_component_overview(value_data: polars.LazyFrame, components: list[str], granularity: str) plotly.graph_objects.Figure

Small-multiples violin panel showing all components side by side.

Each component gets its own subplot with a fully independent x-axis so their different scales are always visible.

Return type:

go.Figure

Parameters:
  • value_data (polars.LazyFrame)

  • components (list[str])

  • granularity (str)

create_win_distribution_plot(data: polars.DataFrame, win_count_col: str, scope_config: dict[str, str | list[str]], title_suffix: str, y_axis_title: str) tuple[plotly.graph_objects.Figure, polars.DataFrame]

Create a win distribution bar chart with highlighted selected items.

This function creates a bar chart showing win counts across actions, groups, or issues based on the scope configuration. It automatically aggregates data appropriately and highlights the selected item in red while showing others in grey.

Parameters:
  • data (pl.DataFrame) – DataFrame containing win distribution data with action identifiers and win counts

  • win_count_col (str) – Column name containing win counts to plot (e.g., “original_win_count”, “new_win_count”)

  • scope_config (dict[str, str | list[str]]) – Configuration dictionary from get_scope_config() containing: - level: “Action”, “Group”, or “Issue” - group_cols: List of columns for grouping - x_col: Column name for x-axis - selected_value: Value to highlight in red - plot_title_prefix: Prefix for plot title

  • title_suffix (str) – Suffix to add to plot title (e.g., “Current Performance”, “After Lever Adjustment”)

  • y_axis_title (str) – Title for y-axis (e.g., “Current Win Count”, “New Win Count”)

Returns:

  • Plotly figure with bar chart

  • Processed plot data (aggregated if needed)

Return type:

tuple[go.Figure, pl.DataFrame]

Notes

  • For Action level: Shows individual actions

  • For Group/Issue level: Automatically aggregates data by summing win counts

  • Selected item is highlighted in red (#FF0000), others in grey

  • “No Winner” bar (if present in data) is shown in orange (#FFA500) to highlight interactions without winners

  • If selected item not found, uses light blue as fallback color

  • X-axis labels are hidden to avoid clutter, scope level shown as x-axis title

  • “No Winner” data is calculated and added by get_win_distribution_data() when all_interactions parameter is provided

Examples

>>> scope_config = get_scope_config("Service", "Cards", "MyAction")
>>> fig, plot_data = create_win_distribution_plot(
...     distribution_data,
...     "new_win_count",
...     scope_config,
...     "After Lever Adjustment",
...     "New Win Count"
... )
create_parameter_distribution_boxplots(segmented_df: polars.DataFrame, parameters: list[str] | None = None, title: str = 'Parameter Distributions: Selected Actions vs Competitors') plotly.graph_objects.Figure

Create box plots comparing parameter distributions between selected actions and others.

Parameters:
  • segmented_df (pl.DataFrame) – DataFrame with columns for parameters and a ‘segment’ column containing “Selected Actions” or “Others”

  • parameters (list[str], optional) – List of parameter column names to plot

  • title (str, optional) – Title for the plot

Returns:

Plotly figure with box plots

Return type:

go.Figure