rectorch.configuration¶
Class list¶
|
Class containing the configurations for reading/writing the data set. |
|
Class containing the configurations for creating, training and testing the model. |
Wrapper class for both the data and model configurations. |
The module contains useful classes to manage the configuration files.
Configuration files are useful to correctly initialize the data processing and the recommendation engines. Configuration files must be .json files with a specific format. Details about the file formats are described in Configuration files format.
-
class
rectorch.configuration.DataConfig(file_path)[source]¶ Class containing the configurations for reading/writing the data set.
Note
The data configuration file must have the structure described in Configuration files format.
-
class
rectorch.configuration.ModelConfig(file_path)[source]¶ Class containing the configurations for creating, training and testing the model.
Note
The data configuration file must have the structure described in Configuration files format.
- Attributes
- modelDefaultMunch
Munch object containing the model’s configurations according to the
modelkey in thefile_pathjson file.- trainDefaultMunch
Munch object containing the model training’s configurations according to the
trainkey in thefile_pathjson file.- testDefaultMunch
Munch object containing the test configurations according to the
testkey in thefile_pathjson file.- samplerDefaultMunch
Munch object containing the sampler configurations according to the
modelkey in thefile_pathjson file.
-
class
rectorch.configuration.ConfigManager(data_config_path, model_config_path)[source]¶ Wrapper class for both the data and model configurations.
Examples
Initializing the ConfigManager singleton:
>>> from rectorch.configuration import ConfigManager
>>> ConfigManager("path/to/the/dataconfig/file", "path/to/the/modelconfig/file")
ConfigManager(data_config=DataConfig(...), model_config=ModelConfig(...))
- Attributes
- data_config
DataConfigObject containing the configurations for reading/writing the data set.
- model_config
ModelConfigObject containing the configurations for creating, training and testing the model.
- data_config
-
classmethod
get()[source]¶ Return the singleton ConfigManager instance.
- Returns
ConfigManagerThe singletion
ConfigManagerinstance.
- Raises
ExceptionRaised when the singleton
ConfigManagerobject has not been previously created. To initialize theConfigManagersimply call its constructor. Please, see Examples.
Examples
>>> from rectorch.configuration import ConfigManager
>>> man = ConfigManager.get()
Exception: Singleton object not instantiated!
The ConfigManager singleton object must be initialized to get it.
>>> ConfigManager("path/to/the/dataconfig/file", "path/to/the/modelconfig/file")
ConfigManager(data_config=DataConfig(...), model_config=ModelConfig(...))
>>> man = ConfigManager.get()
>>> man
ConfigManager(data_config=DataConfig(...), model_config=ModelConfig(...))
Getting the configuration objects is as easy as getting an attribute
>>> man.data_config
DataConfig(...)
>>> man.model_config
ModelConfig(...)