pdstools.ih.Plots

Attributes

Classes

Module Contents

logger
class Plots(ih: pdstools.ih.IH.IH)

Bases: pdstools.utils.namespaces.LazyNamespace

Parameters:

ih (pdstools.ih.IH.IH)

ih
overall_gauges(condition: str | polars.Expr, *, metric: str | None = 'Engagement', by: str | None = 'Channel', reference_values: Dict[str, float] | None = None, title: str | None = None, query: pdstools.utils.types.QUERY | None = None, return_df: bool | None = False)

Creates gauge charts showing overall success rates for different conditions and channels.

This method generates a grid of gauge charts that display success rates for combinations of the specified condition and grouping dimension. Each gauge shows the success rate as a percentage, with optional reference values for comparison.

Parameters:
  • condition (Union[str, pl.Expr]) – The condition to group by (e.g., “Experiment”, “Issue”)

  • metric (Optional[str], optional) – The metric to display success rates for, by default “Engagement”

  • by (Optional[str], optional) – The dimension to group by (e.g., “Channel”), by default “Channel”

  • reference_values (Optional[Dict[str, float]], optional) – Dictionary mapping dimension values to reference values for comparison, by default None

  • title (Optional[str], optional) – Title for the plot, by default None

  • query (Optional[QUERY], optional) – Query to filter the data before aggregation, by default None

  • return_df (Optional[bool], optional) – Whether to return the data frame instead of the plot, by default False

Returns:

A plotly figure with gauge charts or the underlying data frame if return_df is True

Return type:

Union[plotly.graph_objects.Figure, pl.LazyFrame]

response_count_tree_map(*, by: List[str] | None = None, title: str | None = None, query: pdstools.utils.types.QUERY | None = None, return_df: bool | None = False) plotly.graph_objects.Figure | polars.LazyFrame

Creates a treemap visualization showing the distribution of response counts.

This method generates a hierarchical treemap visualization that displays the count of responses across different dimensions. The treemap allows for exploration of how responses are distributed across various categories and subcategories.

Parameters:
  • by (Optional[List[str]], optional) – List of dimensions to include in the hierarchy, by default uses common fields if available

  • title (Optional[str], optional) – Title for the plot, by default None

  • query (Optional[QUERY], optional) – Query to filter the data before aggregation, by default None

  • return_df (Optional[bool], optional) – Whether to return the data frame instead of the plot, by default False

Returns:

A plotly treemap figure or the underlying data frame if return_df is True

Return type:

Union[plotly.graph_objects.Figure, pl.LazyFrame]

success_rate_tree_map(*, metric: str | None = 'Engagement', by: List[str] | None = None, title: str | None = None, query: pdstools.utils.types.QUERY | None = None, return_df: bool | None = False) plotly.graph_objects.Figure | polars.LazyFrame

Creates a treemap visualization showing success rates across different dimensions.

This method generates a hierarchical treemap visualization that displays success rates across different dimensions. The treemap is colored based on the success rate values, allowing for easy identification of high and low performing areas.

Parameters:
  • metric (Optional[str], optional) – The metric to display success rates for, by default “Engagement”

  • by (Optional[List[str]], optional) – List of dimensions to include in the hierarchy, by default uses common fields if available

  • title (Optional[str], optional) – Title for the plot, by default None

  • query (Optional[QUERY], optional) – Query to filter the data before aggregation, by default None

  • return_df (Optional[bool], optional) – Whether to return the data frame instead of the plot, by default False

Returns:

A plotly treemap figure or the underlying data frame if return_df is True

Return type:

Union[plotly.graph_objects.Figure, pl.LazyFrame]

action_distribution(*, by: str | None = 'Name', title: str | None = 'Action Distribution', query: pdstools.utils.types.QUERY | None = None, color: str | None = None, facet: str | None = None, return_df: bool | None = False) plotly.graph_objects.Figure | polars.LazyFrame

Creates a bar chart showing the distribution of actions.

This method generates a bar chart that displays the count of actions across different categories. The chart can be colored by another dimension and faceted for more detailed analysis.

Parameters:
  • by (Optional[str], optional) – The dimension to show on the y-axis, by default “Name”

  • title (Optional[str], optional) – Title for the plot, by default “Action Distribution”

  • query (Optional[QUERY], optional) – Query to filter the data before aggregation, by default None

  • color (Optional[str], optional) – Dimension to use for coloring the bars, by default None

  • facet (Optional[str], optional) – Dimension to use for faceting the chart, by default None

  • return_df (Optional[bool], optional) – Whether to return the data frame instead of the plot, by default False

Returns:

A plotly bar chart or the underlying data frame if return_df is True

Return type:

Union[plotly.graph_objects.Figure, pl.LazyFrame]

success_rate(*, metric: str | None = 'Engagement', every: str | datetime.timedelta = '1d', title: str | None = None, query: pdstools.utils.types.QUERY | None = None, facet: str | None = None, return_df: bool | None = False) plotly.graph_objects.Figure | polars.LazyFrame

Creates a line chart showing success rates over time.

This method generates a line chart that displays success rates for the specified metric over time. The data can be faceted by another dimension for comparative analysis.

Parameters:
  • metric (Optional[str], optional) – The metric to display success rates for, by default “Engagement”

  • every (Union[str, timedelta], optional) – Time interval for aggregation, by default “1d” (daily)

  • title (Optional[str], optional) – Title for the plot, by default None

  • query (Optional[QUERY], optional) – Query to filter the data before aggregation, by default None

  • facet (Optional[str], optional) – Dimension to use for faceting and coloring the chart, by default None

  • return_df (Optional[bool], optional) – Whether to return the data frame instead of the plot, by default False

Returns:

A plotly line chart or the underlying data frame if return_df is True

Return type:

Union[plotly.graph_objects.Figure, pl.LazyFrame]

response_count(*, every: str | datetime.timedelta = '1d', title: str | None = 'Responses', query: pdstools.utils.types.QUERY | None = None, facet: str | None = None, return_df: bool | None = False) plotly.graph_objects.Figure | polars.LazyFrame

Creates a bar chart showing response counts over time.

This method generates a bar chart that displays the count of responses over time, colored by outcome type. The chart can be faceted by another dimension for more detailed analysis.

Parameters:
  • every (Union[str, timedelta], optional) – Time interval for aggregation, by default “1d” (daily)

  • title (Optional[str], optional) – Title for the plot, by default “Responses”

  • query (Optional[QUERY], optional) – Query to filter the data before aggregation, by default None

  • facet (Optional[str], optional) – Dimension to use for faceting the chart, by default None

  • return_df (Optional[bool], optional) – Whether to return the data frame instead of the plot, by default False

Returns:

A plotly bar chart or the underlying data frame if return_df is True

Return type:

Union[plotly.graph_objects.Figure, pl.LazyFrame]

model_performance_trend(*, metric: str | None = 'Engagement', every: str | datetime.timedelta = '1d', by: str | None = None, title: str | None = 'Model Performance over Time', query: pdstools.utils.types.QUERY | None = None, facet: str | None = None, return_df: bool | None = False) plotly.graph_objects.Figure | polars.LazyFrame

Creates a line chart showing model performance (AUC) over time.

This method generates a line chart that displays model performance measured by AUC (Area Under the ROC Curve) over time. The performance is calculated based on propensity scores and actual outcomes. The chart can be colored by one dimension and faceted by another for comparative analysis.

Parameters:
  • metric (Optional[str], optional) – The metric to calculate performance for, by default “Engagement”

  • every (Union[str, timedelta], optional) – Time interval for aggregation, by default “1d” (daily)

  • by (Optional[str], optional) – Dimension to use for coloring the lines, by default None

  • title (Optional[str], optional) – Title for the plot, by default “Model Performance over Time”

  • query (Optional[QUERY], optional) – Query to filter the data before aggregation, by default None

  • facet (Optional[str], optional) – Dimension to use for faceting the chart, by default None

  • return_df (Optional[bool], optional) – Whether to return the data frame instead of the plot, by default False

Returns:

A plotly line chart or the underlying data frame if return_df is True

Return type:

Union[plotly.graph_objects.Figure, pl.LazyFrame]