Skip to main content

FitModelUnit

Unit
DashAI.back.units.FitModelUnit

Train a model, running a hyperparameter search when there is one to run.

Hyperparameter optimization is a fitting strategy rather than a separate step: it returns a fitted model, and the trial plots are a by-product only that branch produces. Both paths therefore live in this unit.

validate resolves the optimizer and the goal metric so an impossible configuration is rejected before the job reports that training started.

The sibling for cross-validation is FitModelOverFoldsUnit: it takes a list of partition sets rather than one, which is a different REQUIRES and therefore a different unit. What surrounds the fit is shared between them; only the objective the search measures, and what happens once the search is over, is written here.

Parameters​

optimizer : object
Optimizer used to search for hyperparameters, along with its own configuration. Only used when the model declares optimizable parameters.
goal_metric : string, default=Accuracy
Metric the hyperparameter search optimizes.
trial_splits : array, default=['TRAIN', 'VALIDATION']
Partitions each trial of the search records a score for. A partition the model is not meant to be judged on belongs out of this list even when metrics are configured for it.
validation_during_fit : boolean, default=True
Whether the validation partition is handed to the model while fitting. Models use it to watch training and stop early. Turn it off when the same partition is what the fit will be scored on.

Methods​

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

Defined on FitModelUnit

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 FitModelUnit

Check preconditions without executing the unit.

Parameters

ctx : ExecutionContext
The shared execution context.

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.