Base Model Classes
Base classes for all models.
- class openadmet.models.architecture.model_base.ModelBase[source]
Bases:
BaseModel,ABCBase class for all models.
- abstract build()[source]
Prepare the model, abstract method to be implemented by subclasses.
- abstract deserialize(param_path: PathLike, serial_path: PathLike)[source]
Deserialize the model, abstract method to be implemented by subclasses.
- Parameters:
param_path (PathLike) – Path to load the model parameters from
serial_path (PathLike) – Path to load the model serialization from
- abstract load(path: PathLike)[source]
Load the model, abstract method to be implemented by subclasses.
- Parameters:
path (PathLike) – Path to load the model from
- 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 predict(input: Any)[source]
Predict using the model, abstract method to be implemented by subclasses.
- Parameters:
input (Any) – Input data to predict on
- abstract save(path: PathLike)[source]
Save the model, abstract method to be implemented by subclasses.
- Parameters:
path (PathLike) – Path to save the model to
- abstract serialize(param_path: PathLike, serial_path: PathLike)[source]
Serialize the model, abstract method to be implemented by subclasses.
- Parameters:
param_path (PathLike) – Path to save the model parameters to
serial_path (PathLike) – Path to save the model serialization to
- abstract train()[source]
Train the model, abstract method to be implemented by subclasses.
- class openadmet.models.architecture.model_base.PickleableModelBase[source]
Bases:
ModelBaseAn sklearn model that can be pickled using joblib.
- load(path: PathLike)[source]
Load the model from a pickle file.
- Parameters:
path (PathLike) – Path to load the model from
- make_new() PickleableModelBase[source]
Copy parameters to a new model instance without copying the estimator.
- 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.
- save(path: PathLike)[source]
Save the model to a pickle file.
- Parameters:
path (PathLike) – Path to save the model to
- serialize(param_path: PathLike = 'model.json', serial_path: PathLike = 'model.pkl')[source]
Save the model to a json file and a pickled file.
- Parameters:
param_path (PathLike) – Path to save the model parameters to
serial_path (PathLike) – Path to save the pickled model to
- openadmet.models.architecture.model_base.get_mod_class(model_type)[source]
Get the model class from the registry by type.
- Parameters:
model_type (str) – The registered key for the model (e.g.,
"XGBRegressorModel").- Returns:
The model class corresponding to the given type.
- Return type:
type
- Raises:
ValueError – If
model_typeis not found in the model registry.