Skip to main content

PredictUnit

Unit
DashAI.back.units.PredictUnit

Predict with a trained model and decode the result into labels.

The rows come in as model_input, the key :class:ApplySessionPreprocessingUnit publishes: the raw rows when the session fitted no preprocessor, the transformed ones when it did. Reading that key rather than dataset is what lets a session that preprocesses predict on the columns its model was trained on while the raw rows stay untouched for whatever saves the prediction next to them.

The input columns are selected against that dataset at this moment, never against a column list captured earlier: whatever built it, a load from disk or hand-typed rows, with or without a preprocessor on top, is free to have produced a different shape.

The training dataset is required rather than reloaded because the task decodes predicted class indexes against its labels. The model is handed the selected columns unprepared: models apply their own preprocessing inside predict, and preparing beforehand would break the ones that replace their input columns with derived features.

Parameters​

task_name : string, default=TabularClassificationTask
Name of the task that turns raw model output into labels.
input_columns : array, default=[]
Names of the columns handed to the model as input.
output_columns : array, default=[]
Names of the columns the model predicts. 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

Defined on PredictUnit

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 PredictUnit

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.