PrepareAndSplitUnit
Validate a dataset against a task and split it once into three partitions.
Runs the task's own validation, counts the labels, separates features from targets and hands the pair to a holdout splitter.
The split configuration is a component field rather than an untyped dictionary: which partitions exist, what they are called and what may be configured are the splitter's own schema, so the front renders that form instead of a free-form object nobody could validate.
The sibling for cross-validation is PrepareAndFoldUnit. They are two
units and not one with a flag for two reasons that both bite. A component
field carries a single parent and the front reads it directly off the
property, so offering two families from one field leaves the user with no
selector at all. And what comes back has a different type -- one
DatasetDict against a list of them -- which a contract that compares
key names cannot express: the same key holding two shapes would validate
statically and fail at run time. The fold unit therefore publishes
x_folds and y_folds rather than reusing x and y.
A session that ran a preprocessing sequence sets two optional fields
together, input_column_refs and preprocessing_artifacts_path.
They are schema fields and not runtime params on purpose: a runtime param
is demanded of every node, and a graph with no preprocessing has nothing
to supply. With them the task is validated on the raw refs alone, the
split carries every raw column, and the one entry is transformed with
final.pkl before it is published, so what comes out is what the
model reads. y is read from the transformed entry too, so a step
that adds or removes rows keeps the target aligned with the inputs.
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 has to predict.
- splitter : object
- Splitter that decides how the dataset is partitioned, along with its own configuration.
- input_column_refs, default=
None - Column references the model reads when the session ran a preprocessing sequence: {'kind': 'raw', 'name': ...} for a column of the dataset, {'kind': 'group', 'step': n} for what converter step n produces. Set together with the artifacts path, or not at all.
- preprocessing_artifacts_path, default=
None - Directory holding the preprocessing fitted for this session, one artifact per split entry. Set together with the input column references, or not at all.
Methods
execute(self, ctx: DashAI.back.units.context.ExecutionContext) -> None
PrepareAndSplitUnitDo 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.