Skip to content

pipeline

Pipeline

Class for chaining different generators together.

Not compatible with scikit-learn Pipelines Only words for python 3.7 as it relies upon dictionaries, and they need to be ordered

Source code in badgers/core/pipeline.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
class Pipeline:
    """
    Class for chaining different generators together.

    Not compatible with scikit-learn Pipelines
    Only words for python 3.7 as it relies upon dictionaries, and they need to be ordered
    """

    def __init__(self, generators: Dict):
        """
        Creates a Pipeline consisting of different generators
        :param generators: a dictionary containing as keys the generator names and as values the generators instances
        """
        self.generators = generators

    def generate(self, X, y, params: Dict = None):
        """
        Calls all generators generate function in the order

        :param X: the input features
        :param y: the class labels, regression targets, or None
        :param params: a dictionary containing as key the generator names and as values the parameters for each corresponding generate function
        :return: Xt, yt
        """
        if params is None:
            params = dict()
        for name, generator in self.generators.items():
            X, y = generator.generate(X, y, **params.get(name, dict()))
        return X, y

__init__(generators)

Creates a Pipeline consisting of different generators :param generators: a dictionary containing as keys the generator names and as values the generators instances

Source code in badgers/core/pipeline.py
14
15
16
17
18
19
def __init__(self, generators: Dict):
    """
    Creates a Pipeline consisting of different generators
    :param generators: a dictionary containing as keys the generator names and as values the generators instances
    """
    self.generators = generators

generate(X, y, params=None)

Calls all generators generate function in the order

:param X: the input features :param y: the class labels, regression targets, or None :param params: a dictionary containing as key the generator names and as values the parameters for each corresponding generate function :return: Xt, yt

Source code in badgers/core/pipeline.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def generate(self, X, y, params: Dict = None):
    """
    Calls all generators generate function in the order

    :param X: the input features
    :param y: the class labels, regression targets, or None
    :param params: a dictionary containing as key the generator names and as values the parameters for each corresponding generate function
    :return: Xt, yt
    """
    if params is None:
        params = dict()
    for name, generator in self.generators.items():
        X, y = generator.generate(X, y, **params.get(name, dict()))
    return X, y