Base Classes for Model Training

Base class for trainers, allows for arbitrary training of models.

class openadmet.models.trainer.trainer_base.TrainerBase[source]

Bases: BaseModel, ABC

Base class for trainers, allows for arbitrary training of models.

Variables:

_model (ModelBase) – The model to be trained.

abstract build()[source]

Build trainer, to be implemented by subclasses.

property model

Return model to be trained.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(context: Any, /) None

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Args:

self: The BaseModel instance. context: The context.

abstract train(X: Any, y: Any)[source]

Train the model, abstract method to be implemented by subclasses.

Parameters:
  • X (Any) – Feature data.

  • y (Any) – Target data.

openadmet.models.trainer.trainer_base.get_trainer_class(model_type)[source]

Retrieve a trainer class from the registry by type.

Parameters:

model_type (str) – The type of trainer to retrieve.

Returns:

The trainer class corresponding to the given type.

Return type:

TrainerBase