Skip to main content

PrepareExplanationDataUnit

Unit
DashAI.back.units.PrepareExplanationDataUnit

Rebuild the exact train/test/val split the run was trained on.

Deliberately not PrepareAndSplitUnit: that one computes a split from a ratio configuration, which would hand the explainer different rows than the model ever saw. This one replays the row indexes the run recorded, so the explanation is about the model that exists.

Features stay unprepared — models apply their own preprocessing inside predict, and preparing beforehand would break the ones that replace their input columns with derived features — while targets are encoded, because explainers compare them against the model's class indexes.

Session preprocessing is another matter: converters the session fitted ahead of training (PreprocessingJob) are not part of the model, and the input columns the session records are the names they produced. When preprocessing_artifacts_path is supplied, the run's split is cut first and the persisted final.pkl is applied to each part, so the explainer's data is in the feature space the model was trained on. Cutting first keeps the run's indexes valid when a step removes rows (NanRemover), and no part is resampled, so no synthetic rows get in. The transformed dataset stays local to this unit: dataset in the context is left as it was loaded, since nothing downstream reads it and a unit that rewrote a key it requires would blur what it consumes and what it produces.

Parameters​

task_name : string, default=TabularClassificationTask
Name of the task the dataset is prepared for.
input_columns : array, default=[]
Names of the columns used as model input.
output_columns : array, default=[]
Names of the columns the model predicts.

Methods​

execute(self, ctx: DashAI.back.units.context.ExecutionContext) -> None

Defined on PrepareExplanationDataUnit

Do the unit's work, reading from and writing to the context.

Parameters

ctx : ExecutionContext
The shared execution context.

validate(self, ctx: DashAI.back.units.context.ExecutionContext) -> None

Defined on PrepareExplanationDataUnit

Resolve the task before anything observable happens.

get_credential(self, name: str)

Defined on ConfigObject

Resolve 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

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It 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.