pdstools.explanations.FilterWidget¶
Classes¶
Module Contents¶
- class FilterWidget(explanations: pdstools.explanations.Explanations.Explanations)¶
Bases:
pdstools.utils.namespaces.LazyNamespace
- Parameters:
explanations (pdstools.explanations.Explanations.Explanations)
- dependencies = ['ipywidgets']¶
- dependency_group = 'explanations'¶
- _ANY_CONTEXT = 'Any'¶
- _CHANGED_VALUE = 'new'¶
- _CHANGED_WIDGET = 'owner'¶
- explanations¶
- _raw_list: List[pdstools.explanations.ExplanationsUtils.ContextInfo] = []¶
- _filtered_list: List[pdstools.explanations.ExplanationsUtils.ContextInfo] = []¶
- _context_operations = None¶
- _selected_context_key = None¶
- interactive()¶
Initializes the interactive filter widget and displays it. This is used in combination with explanations.plot.contributions() to allow users to filter by context if required. Select the context from the list of contexts for plotting contributions for selected context else the overall contributions will be plotted. Alternatively, the context can be set using set_selected_context() method.
- set_selected_context(context_info: pdstools.explanations.ExplanationsUtils.ContextInfo | None = None)¶
Set the selected context information. Args:
- context_info (Optional[ContextInfo]):
If None, initializes the selected context with ‘Any’ for all keys. i.e overall model contributions If provided, sets the selected context to the given context information. Context is passed as a dictionary Eg. context_info =
- {
“pyChannel”: “channel1”, “pyDirection”: “direction1”, …
}
- Parameters:
context_info (Optional[pdstools.explanations.ExplanationsUtils.ContextInfo])
- is_context_selected() bool ¶
Method returns True only if all context keys are selected with a value other than ‘Any’.
- Return type:
- get_selected_context()¶
Get the currently selected context information.
- _init_selected_context()¶
- _display_context_selector()¶
- _get_selected_context(with_any_option: bool = True) pdstools.explanations.ExplanationsUtils.ContextInfo | None ¶
- Parameters:
with_any_option (bool)
- Return type:
Optional[pdstools.explanations.ExplanationsUtils.ContextInfo]
- _get_context_selector_widget() ipywidgets.widgets.Select ¶
- Return type:
ipywidgets.widgets.Select
- _on_button_clicked(_)¶
Clear the filter widget and reset the context selection.
- _on_combobox_change(change)¶
- _on_selector_change(change)¶
- _get_changed_value(change)¶
- _get_changed_widget(change)¶
- _filter_contexts_by_selected() List[pdstools.explanations.ExplanationsUtils.ContextInfo] ¶
- Return type:
List[pdstools.explanations.ExplanationsUtils.ContextInfo]