pdstools.explanations.Plots¶
Classes¶
Module Contents¶
- class Plots(explanations: pdstools.explanations.Explanations.Explanations)¶
Bases:
pdstools.utils.namespaces.LazyNamespace
- Parameters:
explanations (pdstools.explanations.Explanations.Explanations)
- dependencies = ['numpy', 'plotly']¶
- dependency_group = 'explanations'¶
- X_AXIS_TITLE_DEFAULT = 'Contribution'¶
- Y_AXIS_TITLE_DEFAULT = 'Predictor'¶
- explanations¶
- aggregate¶
- contributions(top_n: int = _DEFAULT.TOP_N.value, top_k: int = _DEFAULT.TOP_K.value, descending: bool = _DEFAULT.DESCENDING.value, missing: bool = _DEFAULT.MISSING.value, remaining: bool = _DEFAULT.REMAINING.value, contribution_calculation: str = _CONTRIBUTION_TYPE.CONTRIBUTION.value)¶
Plots contributions for the overall model or a selected context. Args:
- top_n (int):
Number of top predictors to display.
- top_k (int):
Number of top unique values for each categorical predictor to display.
- descending (bool):
Whether to sort the predictors by most or least contribution.
- missing (bool):
Whether to include missing values in the plot.
- remaining (bool):
predictors/predictor values not included in the top_n/top_k will be grouped into a “remaining” category.
- contribution_calculation (str):
Type of contribution calculation to use.
- Returns:
- tuple[go.Figure, List[go.Figure]]:
left: context header if context is selected, otherwise None
right: overall contributions plot and a list of predictor contribution plots.
- plot_contributions_for_overall(top_n: int = _DEFAULT.TOP_N.value, top_k: int = _DEFAULT.TOP_K.value, descending: bool = _DEFAULT.DESCENDING.value, missing: bool = _DEFAULT.MISSING.value, remaining: bool = _DEFAULT.REMAINING.value, contribution_calculation: str = _CONTRIBUTION_TYPE.CONTRIBUTION.value) tuple[plotly.graph_objects.Figure, List[plotly.graph_objects.Figure]] ¶
- plot_contributions_by_context(context: dict[str, str], top_n: int = _DEFAULT.TOP_N.value, top_k: int = _DEFAULT.TOP_K.value, descending: bool = _DEFAULT.DESCENDING.value, missing: bool = _DEFAULT.MISSING.value, remaining: bool = _DEFAULT.REMAINING.value, contribution_calculation: str = _CONTRIBUTION_TYPE.CONTRIBUTION.value) tuple[plotly.graph_objects.Figure, plotly.graph_objects.Figure, List[plotly.graph_objects.Figure]] ¶
- static _plot_overall_contributions(df: polars.DataFrame, x_col: str, y_col: str, x_title: str = X_AXIS_TITLE_DEFAULT, y_title: str = Y_AXIS_TITLE_DEFAULT, context: pdstools.explanations.ExplanationsUtils.ContextInfo | None = None) plotly.graph_objects.Figure ¶
- static _plot_predictor_contributions(df: polars.DataFrame, x_col: str, y_col: str, x_title: str = X_AXIS_TITLE_DEFAULT, y_title: str = Y_AXIS_TITLE_DEFAULT) list[plotly.graph_objects.Figure] ¶
- static _plot_context_table(context_info: pdstools.explanations.ExplanationsUtils.ContextInfo) plotly.graph_objects.Figure ¶
- Parameters:
context_info (pdstools.explanations.ExplanationsUtils.ContextInfo)
- Return type:
plotly.graph_objects.Figure