Skip to content

getml.project.Pipelines

Pipelines(data=None)

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

Example

Show the first 10 pipelines belonging to the current project:

getml.project.pipelines[:10]
You can use nested list comprehensions to retrieve a scoring history for your project:
import matplotlib.pyplot as plt

hyperopt_scores = [(score.date_time, score.mae) for pipe in getml.project.pipelines
                      for score in pipe.scores["data_test"]
                      if "hyperopt" in pipe.tags]

fig, ax = plt.subplots()
ax.bar(*zip(*hyperopt_scores))

Source code in getml/project/containers/pipelines.py
50
51
52
53
54
55
56
def __init__(self, data=None):
    self.ids = list_pipelines()

    if data is None:
        self.data = _refresh_all()
    else:
        self.data = data

sort

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

Sorts the pipelines 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
Pipelines

A container of sorted pipelines.

Example
by_auc = getml.project.pipelines.sort(key=lambda pipe: pipe.auc)
by_fl = getml.project.pipelines.sort(key=lambda pipe: pipe.feature_learners[0].type)
Source code in getml/project/containers/pipelines.py
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
def sort(self, key: Callable, descending: bool = False) -> Pipelines:
    """
    Sorts the pipelines 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 pipelines.

    ??? example
        ```python
        by_auc = getml.project.pipelines.sort(key=lambda pipe: pipe.auc)
        by_fl = getml.project.pipelines.sort(key=lambda pipe: pipe.feature_learners[0].type)
        ```
    """
    pipelines_sorted = sorted(self.data, key=key, reverse=descending)
    return Pipelines(data=pipelines_sorted)

filter

filter(conditional: Callable) -> Pipelines

Filters the pipelines container.

PARAMETER DESCRIPTION
conditional

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

TYPE: Callable

RETURNS DESCRIPTION
Pipelines

A container of filtered pipelines.

Example
pipelines_with_tags = getml.project.pipelines.filter(lambda pipe: len(pipe.tags) > 0)
accurate_pipes = getml.project.pipelines.filter(lambda pipe: all(acc > 0.9 for acc in pipe.accuracy))
Source code in getml/project/containers/pipelines.py
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
def filter(self, conditional: Callable) -> Pipelines:
    """
    Filters the pipelines container.

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

    Returns:
            A container of filtered pipelines.

    ??? example
        ```python
        pipelines_with_tags = getml.project.pipelines.filter(lambda pipe: len(pipe.tags) > 0)
        accurate_pipes = getml.project.pipelines.filter(lambda pipe: all(acc > 0.9 for acc in pipe.accuracy))
        ```
    """
    pipelines_filtered = [
        pipeline for pipeline in self.data if conditional(pipeline)
    ]

    return Pipelines(data=pipelines_filtered)