pdstools.explanations.ExplanationsUtils¶
Attributes¶
Classes¶
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Context related operations such as to filter unique contexts. |
Module Contents¶
- class _PREDICTOR_TYPE(*args, **kwds)¶
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- NUMERIC = 'NUMERIC'¶
- SYMBOLIC = 'SYMBOLIC'¶
- class _TABLE_NAME(*args, **kwds)¶
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- NUMERIC = 'numeric'¶
- SYMBOLIC = 'symbolic'¶
- NUMERIC_OVERALL = 'numeric_overall'¶
- SYMBOLIC_OVERALL = 'symbolic_overall'¶
- CREATE = 'create'¶
- class _CONTRIBUTION_TYPE(default, alt)¶
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- alt¶
- classmethod validate_and_get_type(val)¶
get the accepted contribution type which is validated against user input
- CONTRIBUTION = ('contribution', 'contribution')¶
- CONTRIBUTION_ABS = ('contribution_abs', '|contribution|')¶
- CONTRIBUTION_WEIGHTED = ('contribution_weighted', 'contribution weighted')¶
- CONTRIBUTION_WEIGHTED_ABS = ('contribution_weighted_abs', '|contribution weighted|')¶
- FREQUENCY = ('frequency', 'frequency')¶
- CONTRIBUTION_MIN = ('contribution_min', 'contribution min')¶
- CONTRIBUTION_MAX = ('contribution_max', 'contribution max')¶
- class _COL(*args, **kwds)¶
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- PARTITON = 'partition'¶
- PREDICTOR_NAME = 'predictor_name'¶
- PREDICTOR_TYPE = 'predictor_type'¶
- BIN_CONTENTS = 'bin_contents'¶
- BIN_ORDER = 'bin_order'¶
- CONTRIBUTION = 'contribution'¶
- CONTRIBUTION_ABS = 'contribution_abs'¶
- CONTRIBUTION_MIN = 'contribution_min'¶
- CONTRIBUTION_MAX = 'contribution_max'¶
- CONTRIBUTION_WEIGHTED = 'contribution_weighted'¶
- CONTRIBUTION_WEIGHTED_ABS = 'contribution_weighted_abs'¶
- FREQUENCY = 'frequency'¶
- class _SPECIAL(*args, **kwds)¶
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- REMAINING = 'remaining'¶
- TOTAL_FREQUENCY = 'total_frequency'¶
- MISSING = 'missing'¶
- class _DEFAULT(*args, **kwds)¶
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- TOP_N = 10¶
- TOP_K = 10¶
- DESCENDING = True¶
- MISSING = True¶
- REMAINING = True¶
- ContextInfo¶
- class ContextOperations(aggregate: pdstools.explanations.Aggregate.Aggregate)¶
Bases:
pdstools.utils.namespaces.LazyNamespace
Context related operations such as to filter unique contexts. Parameters:
aggregate (Aggregate): The aggregate object to operate on.
- Attributes:
aggregate (Aggregate): The aggregate object. _df (Optional[pl.DataFrame]): DataFrame containing context information. _context_keys (Optional[List[str]]): List of context keys. initialized (bool): Flag indicating if the context operations have been initialized.
- Methods:
- get_context_keys():
Returns the list of context keys from loaded data. Eg. [‘pyChannel’, ‘pyDirection’, …]
- get_df(context_infos=None, with_partition_col=False):
Returns a DataFrame containing unique contexts If with_partition_col is True, includes the partition column. If context_infos is None, returns the full unique contexts, else filtered by the context Eg. with partition column: | pyChannel | pyDirection | … | partition | |-----------|————-|-----|———–| | channel1 | direction1 | … | {“partition”: {“pyChannel”: “channel1”, “pyDirection”: “direction1”}} | | channel1 | direction2 | … | {“partition”: {“pyChannel”: “channel1”, “pyDirection”: “direction2”}} |
- get_list(context_infos=None, with_partition_col=False):
Returns a List[ContextInfo] containing unique contexts If with_partition_col is True, includes the partition column. If context_infos is None, returns the full unique contexts, else filtered by the context Eg. without partition column: [
{“pyChannel”: “channel1”, “pyDirection”: “direction1”, …}, {“pyChannel”: “channel1”, “pyDirection”: “direction2”, …},
]
- get_context_info_str(context_info, sep=”-“):
Returns a string representation of a single context information. Eg. channel1-direction1-…
- Parameters:
aggregate (pdstools.explanations.Aggregate.Aggregate)
- dependencies = ['polars']¶
- dependency_group = 'explanations'¶
- aggregate¶
- initialized = False¶
- _load()¶
- get_context_keys()¶
- get_df(context_infos: List[ContextInfo] | None = None, with_partition_col: bool = False) polars.DataFrame ¶
Get the DataFrame filtered by the provided context information.
- Parameters:
context_infos (Optional[List[ContextInfo]])
with_partition_col (bool)
- Return type:
polars.DataFrame
- get_list(context_infos: List[ContextInfo] | None = None, with_partition_col: bool = False) List[ContextInfo] ¶
Get the list of context information filtered by the provided context information.
- Parameters:
context_infos (Optional[List[ContextInfo]])
with_partition_col (bool)
- Return type:
List[ContextInfo]
- _filter_df_by_context_infos(df, context_infos)¶
- static _get_filter_expression(context_infos)¶
- static _get_clean_df(df: polars.DataFrame) polars.DataFrame ¶
- Parameters:
df (polars.DataFrame)
- Return type:
polars.DataFrame