Coverage for addmo/s3_model_tuning/hyperparameter_tuning/abstract_hyparam_tuner.py: 91%
11 statements
« prev ^ index » next coverage.py v7.4.4, created at 2025-08-31 13:05 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2025-08-31 13:05 +0000
1from abc import ABC, abstractmethod
2from addmo.s3_model_tuning.models.abstract_model import AbstractMLModel
3from addmo.s3_model_tuning.config.model_tuning_config import ModelTuningExperimentConfig
4from addmo.s3_model_tuning.scoring.abstract_scorer import ValidationScoring
7class AbstractHyParamTuner(ABC):
8 """
9 Abstract class for hyperparameter tuning.
10 """
12 def __init__(
13 self,
14 config: ModelTuningExperimentConfig,
15 scorer: ValidationScoring,
16 ):
17 self.config = config
18 self.scorer = scorer
20 @abstractmethod
21 def tune(self, model:AbstractMLModel, x_train_val, y_train_val, **kwargs):
22 """
23 Abstract method for performing hyperparameter tuning.
24 Returns the best hyperparameters found in the structure provided by the model.
25 Also sets the model's hyperparameters to the best found.
26 """
27 raise NotImplementedError("Subclasses must implement this method.")