Skip to content

Trainer

fyt.core.trainer

Model training and prediction.

The Trainer is responsible only for model fitting and prediction. Hyperparameter optimization, metrics computation, and experiment logging are handled by dedicated collaborators (HyperparameterOptimizer, MetricsEvaluator, ExperimentReporter).

Trainer

Trains machine learning models and makes predictions.

Parameters:

Name Type Description Default
config TrainerConfig

Configuration for the trainer.

required
random_state int

Random state for reproducibility.

42

best_params property writable

The best hyperparameters from Optuna optimization.

model property

The trained model.

Raises:

Type Description
ValueError

If the model has not been trained yet.

model_params property

A copy of the base model parameters (the config is the truth).

model_type property

The model type identifier.

random_state property writable

The random state.

predict(X)

Make predictions using the trained model.

Parameters:

Name Type Description Default
X DataFrame

Feature data for prediction.

required

Returns:

Type Description
Series

Predicted values.

Raises:

Type Description
ValueError

If the model has not been trained.

predict_proba(X)

Make probability predictions using the trained model.

Parameters:

Name Type Description Default
X DataFrame

Feature data for prediction.

required

Returns:

Type Description
DataFrame

Predicted probabilities.

Raises:

Type Description
ValueError

If the model has not been trained or doesn't support predict_proba.

train(data_split)

Train the model on the provided data split.

Parameters:

Name Type Description Default
data_split DataSplit

Data split containing training and testing data.

required

Raises:

Type Description
ValueError

If the configured model type is not supported.