Skip to content

getml.project.Hyperopts

Hyperopts(data=None)

Container which holds all hyperopts associated with the currently running project. The container supports slicing and is sort- and filterable.

Source code in getml/project/containers/hyperopts.py
32
33
34
35
36
37
38
def __init__(self, data=None):
    self.ids = list_hyperopts()

    if data is None:
        self.data = [load_hyperopt(id) for id in self.ids]
    else:
        self.data = data

filter

filter(conditional: Callable) -> Hyperopts

Filters the hyperopts container.

PARAMETER DESCRIPTION
conditional

A callable that evaluates to a boolean for a given item.

TYPE: Callable

RETURNS DESCRIPTION
Hyperopts

A container of filtered hyperopts.

Example
gaussian_hyperopts = getml.project.hyperopts.filter(lamda hyp: "Gaussian" in hyp.type)
Source code in getml/project/containers/hyperopts.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
def filter(self, conditional: Callable) -> Hyperopts:
    """
    Filters the hyperopts container.

    Args:
        conditional:
            A callable that evaluates to a boolean for a given item.

    Returns:
            A container of filtered hyperopts.

    ??? example
        ```python
        gaussian_hyperopts = getml.project.hyperopts.filter(lamda hyp: "Gaussian" in hyp.type)
        ```
    """
    hyperopts_filtered = [
        hyperopt for hyperopt in self.data if conditional(hyperopt)
    ]
    return Hyperopts(data=hyperopts_filtered)

sort

sort(key: Callable, descending: bool = False) -> Hyperopts

Sorts the hyperopts container.

PARAMETER DESCRIPTION
key

A callable that evaluates to a sort key for a given item.

TYPE: Callable

descending

Whether to sort in descending order.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Hyperopts

A container of sorted hyperopts.

Example
by_type = getml.project.hyperopt.sort(lambda hyp: hyp.type)
Source code in getml/project/containers/hyperopts.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def sort(self, key: Callable, descending: bool = False) -> Hyperopts:
    """
    Sorts the hyperopts container.

    Args:
        key:
            A callable that evaluates to a sort key for a given item.

        descending:
            Whether to sort in descending order.

    Returns:
            A container of sorted hyperopts.

    ??? example
        ```python
        by_type = getml.project.hyperopt.sort(lambda hyp: hyp.type)
        ```
    """
    hyperopts_sorted = sorted(self.data, key=key, reverse=descending)
    return Hyperopts(data=hyperopts_sorted)