Model training.
Functions
execute_train(**kwargs) -> Dict[str, Any]
Execute the training workflow behind the tuiml_train tool.
Supports staged execution (
init / fit / partial_fit / cross_validate) as well as the default full pipeline via tuiml.train(). The trained model is saved to disk and indexed so other tools can load it by model_id.Parameters
algorithm
str
Registered algorithm class name to train (arrives via
**kwargs, like all parameters below). Required unless a model_id / model_path is given for a stage that loads an existing model.
algorithm_params
dict
= None
Constructor parameters for the algorithm.
data
str
Dataset to train on: uploaded dataset_id, file path, or built-in dataset name. Required for the default path and for the
fit / partial_fit stages.
stage
str
= None
Optional atomic stage:
'init' (instantiate and save an unfitted model), 'fit', 'partial_fit' (incremental training), or 'cross_validate'. When None the full train pipeline runs.
stage_kwargs
dict
= None
Extra keyword arguments for the selected stage (e.g.
classes for partial_fit, cv for cross_validate).
model_id
str
= None
Existing model to continue training (
fit / partial_fit).
model_path
str
= None
Explicit path to an existing serialized model.
save_path
str
= None
Where to save the trained model; defaults to
~/.tuiml/models/.
preset
str
= None
Named preprocessing preset used when no explicit steps are given.
preprocessing
list
= None
Preprocessing steps, each a name or
{"name", **params} dict.
feature_selection
dict
= None
Feature-selection step appended to the pipeline.
cv
int
= None
Number of cross-validation folds.
test_size
float
= None
Holdout fraction for evaluation.
stratify
bool
= None
Whether to stratify the evaluation split.
metrics
list of str
= None
Metrics to compute during evaluation.
random_seed
int
= None
Random seed; falls back to the global seed, then 42.
Returns
result
dict
On success:
status ('success'), model_id, model_path and model_class; the full-pipeline path also includes metrics, cv_results and metadata. On failure: status ('error'), error, and optionally error_type, suggestion, recovery_tool and recovery_params.