GenerateLocalExplanationUnit
Explain a selection of instances and pickle the result.
Sibling of GenerateGlobalExplanationUnit; see that class for why the
two scopes are two units and not one with a branch.
The three ways of choosing instances — a share of a split, the rows the user marked, or hand-typed values — stay one unit on purpose. They are three branches of a single decision with a single output; as separate nodes exactly one could ever run, which the contract cannot express.
Row indexes are never taken on trust across datasets: when the instances
come from a dataset other than the one the run was trained on, the run's
indexes address rows that do not correspond, so the split is recomputed
from the session's ratios instead. That derived state is resolved here,
inside execute, and never published.
When the session preprocessed its data ahead of training, the instances
are transformed by the persisted final.pkl before anything selects
columns from them: the input columns the session records are the names
the converters produced, which the raw rows do not have. The explainer
was fitted on data PrepareExplanationDataUnit transformed the same
way, so both sides of the explanation meet in the model's feature space.
Parameters
- explainer_id : integer, default=
1 - Identifier of the local explanation being produced. It names the files on disk, so a re-run overwrites its own artifacts.
- instance_dataset_id : integer, default=
1 - Identifier of the dataset the explained instances come from. It may differ from the one the model was trained on.
- scope : object
- Which instances to explain. A 'mode' of 'split' takes a share of one data split, 'rows' takes the row indexes the user marked, and 'manual' takes hand-typed values. Defaults to 'split'.
- fit_parameters : object
- Extra arguments handed to the explainer's fit step.
- input_columns : array, default=
[] - Names of the columns used as model input.
- output_columns : array, default=
[] - Names of the columns the model predicts.
- manual_input_data, default=
None - Rows to explain when the scope mode is 'manual'. Ignored otherwise.
- same_dataset : boolean, default=
True - Whether the instances come from the very dataset the model was trained on. When they do not, the run's row indexes mean nothing here and the split has to be recomputed.
Methods
execute(self, ctx: DashAI.back.units.context.ExecutionContext) -> None
GenerateLocalExplanationUnitDo the unit's work, reading from and writing to the context.
Parameters
- ctx : ExecutionContext
- The shared execution context.
get_credential(self, name: str)
ConfigObjectResolve a registered credential component by name.
Parameters
- name : str
- Credential component class name (e.g. "HuggingFaceCredential").
Returns
- BaseCredential
- An instance of the requested credential component.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
validate(self, ctx: DashAI.back.units.context.ExecutionContext) -> None
BaseUnitCheck preconditions without executing the unit.
Parameters
- ctx : ExecutionContext
- The shared execution context.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.