stouputils.data_science.models.abstract_model module#

Abstract base class for all model implementations. Defines the interface that all concrete model classes must implement.

Provides abstract methods for core model operations including:

  • Class routine management

  • Model loading

  • Training procedures

  • Prediction functionality

  • Evaluation metrics

Classes inheriting from AbstractModel must implement all methods.

class AbstractModel(
num_classes: int,
kfold: int = 0,
transfer_learning: str = 'imagenet',
**override_params: Any,
)[source]#

Bases: object

Abstract class for all models to copy and implement the methods.

routine_full(
dataset: Dataset,
verbose: int = 0,
) AbstractModel[source]#

Function ‘routine_full’ is abstract and must be implemented by a subclass

class_load() None[source]#

Function ‘class_load’ is abstract and must be implemented by a subclass

class_train(
dataset: Dataset,
verbose: int = 0,
) bool[source]#

Function ‘class_train’ is abstract and must be implemented by a subclass

class_predict(
X_test: Iterable[Any],
) Iterable[Any][source]#

Function ‘class_predict’ is abstract and must be implemented by a subclass

class_evaluate(
dataset: Dataset,
metrics_names: tuple[str, ...] = (),
save_model: bool = False,
verbose: int = 0,
) bool[source]#

Function ‘class_evaluate’ is abstract and must be implemented by a subclass

_fit(
model: Any,
x: Any,
y: Any | None = None,
validation_data: tuple[Any, Any] | None = None,
shuffle: bool = True,
batch_size: int | None = None,
epochs: int = 1,
callbacks: list[Any] | None = None,
class_weight: dict[int, float] | None = None,
verbose: int = 0,
*args: Any,
**kwargs: Any,
) Any[source]#

Function ‘_fit’ is abstract and must be implemented by a subclass

_get_callbacks() list[Any][source]#

Function ‘_get_callbacks’ is abstract and must be implemented by a subclass

_get_metrics() list[Any][source]#

Function ‘_get_metrics’ is abstract and must be implemented by a subclass

_get_optimizer(
learning_rate: float = 0.0,
) Any[source]#

Function ‘_get_optimizer’ is abstract and must be implemented by a subclass

_get_loss() Any[source]#

Function ‘_get_loss’ is abstract and must be implemented by a subclass

_get_base_model() Any[source]#

Function ‘_get_base_model’ is abstract and must be implemented by a subclass

_get_architectures(
optimizer: Any = None,
loss: Any = None,
metrics: list[Any] | None = None,
) tuple[Any, Any][source]#

Function ‘_get_architectures’ is abstract and must be implemented by a subclass

_find_best_learning_rate(
dataset: Dataset,
verbose: int = 0,
) float[source]#

Function ‘_find_best_learning_rate’ is abstract and must be implemented by a subclass

_train_fold(
dataset: Dataset,
fold_number: int = 0,
mlflow_prefix: str = 'history',
verbose: int = 0,
) Any[source]#

Function ‘_train_fold’ is abstract and must be implemented by a subclass

_log_final_model() None[source]#

Function ‘_log_final_model’ is abstract and must be implemented by a subclass

_find_best_learning_rate_subprocess(
dataset: Dataset,
queue: Queue[Any] | None = None,
verbose: int = 0,
) dict[str, Any] | None[source]#

Function ‘_find_best_learning_rate_subprocess’ is abstract and must be implemented by a subclass

_find_best_unfreeze_percentage_subprocess(
dataset: Dataset,
queue: Queue[Any] | None = None,
verbose: int = 0,
) dict[str, Any] | None[source]#

Function ‘_find_best_unfreeze_percentage_subprocess’ is abstract and must be implemented by a subclass

_train_subprocess(
dataset: Dataset,
checkpoint_path: str,
temp_dir: TemporaryDirectory[str] | None = None,
queue: Queue[Any] | None = None,
verbose: int = 0,
) dict[str, Any] | None[source]#

Function ‘_train_subprocess’ is abstract and must be implemented by a subclass