models_configs¶
This module provides classes for managing and validating configuration parameters for various machine learning models, specifically focusing on ARIMA-based models. The module includes a base class that standardizes the process of handling model configuration, ensuring that all derived classes follow a consistent pattern for validating and setting parameters.
Classes¶
- AbstractBaseModelConfigABC
An abstract base class for the
BaseModelConfigclass.- BaseModelConfigAbstractBaseModelConfig
A base class that provides common functionality for model configuration, including parameter validation, default value handling, and error checking. Subclasses are required to define a
SUPPORTED_PARAMETERSdictionary that specifies the expected parameter types, default values, and any valid choices.- ARIMAConfigBaseModelConfig
A configuration class for ARIMA model parameters. Inherits from
BaseModelConfigand defines specific parameters used by ARIMA and ARIMA_PLUS models. This class ensures that the parameters adhere to the expected types and valid choices.- ARIMA_PLUS_XREG_ConfigBaseModelConfig
A configuration class for ARIMA_PLUS_XREG model parameters. This class extends
BaseModelConfigand includes additional parameters for handling exogenous variables (xreg_features) and other settings specific to theARIMA_PLUS_XREGmodel.
Usage¶
These configuration classes are intended to be used in the setup and validation of model parameters before they are passed to machine learning model training functions. By leveraging these classes, developers can ensure that all configuration parameters are correctly typed, fall within valid ranges, and adhere to expected choices, reducing the likelihood of runtime errors.
Example
>>> config = ARIMAConfig(model_type="ARIMA")
>>> print(config.model_type)
'ARIMA'
>>> xreg_config = ARIMA_PLUS_XREG_Config(
... model_type="ARIMA_PLUS_XREG",
... xreg_features=["feature1", "feature2"],
... non_negative_forecast=True
... )
>>> print(xreg_config.xreg_features)
['feature1', 'feature2']
- class iowa_forecast.models_configs.AbstractBaseModelConfig[source]¶
Bases:
ABCAbstract base class for
BaseModelConfigconfiguration class.- Attributes:
SUPPORTED_PARAMETERSThis abstract property must be implemented by subclasses.
- abstract property SUPPORTED_PARAMETERS: Dict[str, Tuple[Any, Any, List[Any]]]¶
This abstract property must be implemented by subclasses. It should return a dictionary where the keys are parameter names, and the values are tuples containing the expected type, default value, and a list of valid choices (if any).
- class iowa_forecast.models_configs.BaseModelConfig(**kwargs)[source]¶
Bases:
AbstractBaseModelConfigBase class for model configuration parameters.
This class provides common functionality for handling configuration parameters passed via kwargs, including unpacking, validation, and setting default values.
Subclasses must define the
SUPPORTED_PARAMETERSdictionary, which specifies the expected parameter types, default values, and any restricted choices.- Attributes:
SUPPORTED_PARAMETERSThis abstract property must be implemented by subclasses.
- property SUPPORTED_PARAMETERS: Dict[str, Tuple[Any, Any, List[Any]]]¶
This abstract property must be implemented by subclasses. It should return a dictionary where the keys are parameter names, and the values are tuples containing the expected type, default value, and a list of valid choices (if any).
- class iowa_forecast.models_configs.ARIMAConfig(**kwargs)[source]¶
Bases:
BaseModelConfigConfiguration class for
'ARIMA'model parameters.Inherits common functionality from
BaseModelConfigand defines specific parameters for'ARIMA'models, including validation of choices for some parameters.- Attributes:
SUPPORTED_PARAMETERSThis abstract property must be implemented by subclasses.
- property SUPPORTED_PARAMETERS: Dict[str, Tuple[Any, Any, List[Any]]]¶
This abstract property must be implemented by subclasses. It should return a dictionary where the keys are parameter names, and the values are tuples containing the expected type, default value, and a list of valid choices (if any).
- class iowa_forecast.models_configs.ARIMA_PLUS_XREG_Config(**kwargs)[source]¶
Bases:
BaseModelConfigConfiguration class for
'ARIMA_PLUS_XREG'model parameters.Inherits common functionality from
BaseModelConfigand defines specific parameters for'ARIMA_PLUS_XREG'models, including validation of choices for some parameters.- Attributes:
SUPPORTED_PARAMETERSThis abstract property must be implemented by subclasses.
- property SUPPORTED_PARAMETERS: Dict[str, Tuple[Any, Any, List[Any]]]¶
This abstract property must be implemented by subclasses. It should return a dictionary where the keys are parameter names, and the values are tuples containing the expected type, default value, and a list of valid choices (if any).