Skip to content

river_hyper_dict

RiverHyperDict

Bases: FileConfig

River hyperparameter dictionary.

Source code in spotriver/hyperdict/river_hyper_dict.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class RiverHyperDict(base.FileConfig):
    """River hyperparameter dictionary."""

    def __init__(
        self,
        filename: str = "river_hyper_dict.json",
        directory: None = None,
    ) -> None:
        super().__init__(filename=filename, directory=directory)
        self.filename = filename
        self.directory = directory
        self.hyper_dict = self.load()
        self.scenario = "river"

    @property
    def path(self):
        if self.directory:
            return pathlib.Path(self.directory).joinpath(self.filename)
        return pathlib.Path(__file__).parent.joinpath(self.filename)

    def get_scenario(self):
        return self.scenario

    def load(self) -> dict:
        """Load the hyperparameters from the file.

        Returns:
            dict: A dictionary containing the hyperparameters.

        """
        with open(self.path, "r") as f:
            d = json.load(f)
        return d

load()

Load the hyperparameters from the file.

Returns:

Name Type Description
dict dict

A dictionary containing the hyperparameters.

Source code in spotriver/hyperdict/river_hyper_dict.py
29
30
31
32
33
34
35
36
37
38
def load(self) -> dict:
    """Load the hyperparameters from the file.

    Returns:
        dict: A dictionary containing the hyperparameters.

    """
    with open(self.path, "r") as f:
        d = json.load(f)
    return d