pdstools.decision_analyzer.utils

Attributes

Functions

apply_filter(df[, filters])

Apply a global set of filters. Kept outside of the DecisionData class as

filtered_action_counts(→ polars.LazyFrame)

Returns a DataFrame with action counts filtered based on the given propensity and priority thresholds.

area_under_curve(df, col_x, col_y)

gini_coefficient(df, col_x, col_y)

get_first_level_stats(interaction_data[, filters])

Returns some first level stats of a dataframe. Used to

get_git_version_and_date()

find_lever_value(decision_data, action, ...[, low, ...])

Binary search algorithm to find lever given a desired win percentage

determine_extract_type(raw_data)

process(→ polars.LazyFrame)

get_table_definition(table)

get_schema(→ Dict[str, Type[polars.DataType]])

Module Contents

NBADScope_Mapping
apply_filter(df: polars.LazyFrame, filters: polars.Expr | List[polars.Expr] | None = None)

Apply a global set of filters. Kept outside of the DecisionData class as this is really more of a utility function, not bound to that class at all.

Parameters:
  • df (polars.LazyFrame)

  • filters (Optional[Union[polars.Expr, List[polars.Expr]]])

filtered_action_counts(df: polars.LazyFrame, groupby_cols: list, propensityTH: float = None, priorityTH: float = None) polars.LazyFrame

Returns a DataFrame with action counts filtered based on the given propensity and priority thresholds.

Parameters:
  • df (pl.LazyFrame) – The input dataframe.

  • groupby_cols (list) – The list of column names to group by([“pxEngagementStage”, “pxInteractionID”]).

  • propensityTH (float) – The propensity threshold.

  • priorityTH (float) – The priority threshold.

Returns:

A DataFrame with action counts filtered based on the given propensity and priority thresholds.

Return type:

pl.LazyFrame

area_under_curve(df: polars.DataFrame, col_x: str, col_y: str)
Parameters:
  • df (polars.DataFrame)

  • col_x (str)

  • col_y (str)

gini_coefficient(df: polars.DataFrame, col_x: str, col_y: str)
Parameters:
  • df (polars.DataFrame)

  • col_x (str)

  • col_y (str)

get_first_level_stats(interaction_data: polars.LazyFrame, filters: List[polars.Expr] = None)

Returns some first level stats of a dataframe. Used to show effects of user data filters.

Parameters:
  • interaction_data (polars.LazyFrame)

  • filters (List[polars.Expr])

get_git_version_and_date()
find_lever_value(decision_data, action, target_win_percentage, win_rank, low=0, high=100, precision=0.01, ranking_stages=['Arbitration'])

Binary search algorithm to find lever given a desired win percentage

determine_extract_type(raw_data)
process(df: polars.LazyFrame, table: Literal['decision_analyzer', 'explainability_extract'], subset: bool = True, include_cols: Iterable[str] | None = None, drop_cols: Iterable[str] | None = None, raise_on_unknown: bool = True) polars.LazyFrame
Parameters:
  • df (polars.LazyFrame)

  • table (Literal['decision_analyzer', 'explainability_extract'])

  • subset (bool)

  • include_cols (Optional[Iterable[str]])

  • drop_cols (Optional[Iterable[str]])

  • raise_on_unknown (bool)

Return type:

polars.LazyFrame

get_table_definition(table: str)
Parameters:

table (str)

get_schema(df: polars.LazyFrame, table_definition: Dict[str, pdstools.decision_analyzer.table_definition.TableConfig], include_cols: Iterable[str], drop_cols: Iterable[str], subset: bool, raise_on_unknown: bool = True) Dict[str, Type[polars.DataType]]
Parameters:
Return type:

Dict[str, Type[polars.DataType]]