pdstools.decision_analyzer.plots¶
Classes¶
Functions¶
|
|
|
|
|
|
Create a win distribution bar chart with highlighted selected items. |
|
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)¶
- sensitivity(win_rank: int = 1, hide_priority=True, limit_xaxis_range=True, return_df=False, reference_group=None)¶
- 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] ¶
- decision_funnel(scope: str, additional_filters: polars.Expr | List[polars.Expr] | None = None, return_df=False)¶
- Parameters:
scope (str)
additional_filters (Optional[Union[polars.Expr, List[polars.Expr]]])
- 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 (Optional[Union[polars.Expr, List[polars.Expr]]])
- distribution(df: polars.LazyFrame, scope: str, breakdown: str, metric: str = 'Decisions', horizontal=False)¶
- prio_factor_boxplots(reference: polars.Expr | List[polars.Expr] | None = None, return_df=False) Tuple[plotly.graph_objects.Figure, str | None] ¶
- Parameters:
reference (Optional[Union[polars.Expr, List[polars.Expr]]])
- Return type:
Tuple[plotly.graph_objects.Figure, Optional[str]]
- rank_boxplot(reference: polars.Expr | List[polars.Expr] | None = None, return_df=False)¶
- Parameters:
reference (Optional[Union[polars.Expr, List[polars.Expr]]])
- 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='StageGroup')¶
- Parameters:
df (polars.LazyFrame)
- getTrendChart(df: polars.LazyFrame, stage: str = 'Output', return_df=False, level='StageGroup')¶
- Parameters:
df (polars.LazyFrame)
stage (str)
- plot_priority_component_distribution(value_data: polars.LazyFrame, component: 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, Union[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] = ['Propensity', 'Value', 'Context Weight', 'Levers'], title: str = 'Parameter Distributions: Selected Actions vs Competitors') plotly.graph_objects.Figure ¶
Create box plots comparing parameter distributions between selected actions and others.
- Parameters:
- Returns:
Plotly figure with box plots
- Return type:
go.Figure