SavePredictionUnit
Write the predicted column next to the data it was predicted from.
The destination is a fresh folder under the datasets directory, named by a generated identifier: a prediction has no natural key to overwrite, so every run gets its own and no result can clobber another's.
The columns to keep are resolved against the dataset the context holds right now, at the top of this method. Publishing a column list earlier would go stale the moment anything upstream renamed, added or dropped a column.
The task is configuration, the same way PredictUnit receives it, and
it is consulted for one thing: a regression predicts continuous values
whatever type its target was trained as, so the predicted column is
declared as a float rather than inheriting the training dataset's type.
Inheriting it is not harmless: an integer-typed target makes the save cast
1.5 to int64, and Arrow refuses the truncation.
Parameters
- task_name : string, default=
TabularClassificationTask - Name of the task the model was trained for. It decides the declared type of the predicted column: a regression predicts continuous values whatever type its target was trained as.
- input_columns : array, default=
[] - Names of the model input columns. Together with the output column they decide which declared types are kept in the schema written next to the result.
- output_columns : array, default=
[] - Names of the predicted columns. Only the first one is used: it names the column the predictions are written to.
Methods
execute(self, ctx: DashAI.back.units.context.ExecutionContext) -> None
SavePredictionUnitDo 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.