How to use the neuraxle.base.BaseStep function in neuraxle

To help you get started, we’ve selected a few neuraxle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Neuraxio / Neuraxle / testing / mocks / step_mocks.py View on Github external
'learning_rate': 0.1,
    'l2_weight_reg': 0.001,
    'hidden_size': 32,
    'num_layers': 3,
    'num_lstm_layers': 1,
    'use_xavier_init': True,
    'use_max_pool_else_avg_pool': True,
    'dropout_drop_proba': 0.5,
    'momentum': 0.1
})

AN_INPUT = "I am an input"
AN_EXPECTED_OUTPUT = "I am an expected output"


class SomeStep(NonFittableMixin, BaseStep):
    def __init__(self, hyperparams_space: HyperparameterSpace = None, output=AN_EXPECTED_OUTPUT):
        BaseStep.__init__(self, hyperparams=None, hyperparams_space=hyperparams_space)
        NonFittableMixin.__init__(self)
        self.output = output

    def transform(self, data_inputs):
        return [self.output] * len(data_inputs)


class SomeStepWithHyperparams(BaseStep):
    def __init__(self):
        BaseStep.__init__(self,
                          hyperparams=HYPERPARAMETERS,
                          hyperparams_space=HYPERPARAMETERS_SPACE,
                          name="MockStep"
                          )
github Neuraxio / Neuraxle / neuraxle / steps / data.py View on Github external
def __init__(self, seed, increment_seed_after_each_fit=True):
        InputAndOutputTransformerMixin.__init__(self)
        BaseStep.__init__(self)
        self.seed = seed
        self.increment_seed_after_each_fit = increment_seed_after_each_fit
github Neuraxio / Neuraxle / neuraxle / steps / output_handlers.py View on Github external
Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

..
    Thanks to Umaneo Technologies Inc. for their contributions to this Machine Learning
    project, visit https://www.umaneo.com/ for more information on Umaneo Technologies Inc.

"""
from neuraxle.base import ExecutionContext, BaseStep, MetaStepMixin
from neuraxle.data_container import DataContainer


class OutputTransformerWrapper(MetaStepMixin, BaseStep):
    """
    Transform expected output wrapper step that can sends the expected_outputs to the wrapped step
    so that it can transform the expected outputs.
    """

    def __init__(self, wrapped):
        MetaStepMixin.__init__(self, wrapped)
        BaseStep.__init__(self)

    def handle_transform(self, data_container: DataContainer, context: ExecutionContext) -> DataContainer:
        new_expected_outputs_data_container = self.wrapped.handle_transform(
            DataContainer(
                current_ids=data_container.current_ids,
                data_inputs=data_container.expected_outputs,
                expected_outputs=None
            ),
github Neuraxio / Neuraxle / neuraxle / steps / column_transformer.py View on Github external
from typing import List, Tuple, Union

import numpy as np

from neuraxle.base import BaseStep, NonFittableMixin, MetaStepMixin
from neuraxle.pipeline import Pipeline
from neuraxle.steps.loop import ForEachDataInput
from neuraxle.union import FeatureUnion

ColumnSelectionType = Union[Tuple[int, BaseStep], Tuple[List[int], BaseStep], Tuple[slice, BaseStep]]
ColumnChooserTupleList = List[ColumnSelectionType]


class ColumnSelector2D(NonFittableMixin, BaseStep):
    """
    A ColumnSelector2D selects column in a sequence.
    """

    def __init__(self, columns_selection: ColumnSelectionType):
        super().__init__()
        self.column_selection = columns_selection

    def transform(self, data_inputs):
        if isinstance(self.column_selection, range):
            self.column_selection = slice(
                self.column_selection.start,
github Neuraxio / Neuraxle / neuraxle / steps / flow.py View on Github external
from neuraxle.base import MetaStepMixin, BaseStep, ExecutionContext, DataContainer, NonTransformableMixin, \
    ExecutionMode, NonFittableMixin, ForceHandleMixin


class TransformOnlyWrapper(
    NonTransformableMixin,
    NonFittableMixin,
    MetaStepMixin,
    BaseStep
):
    """
    A wrapper step that makes its wrapped step only executes in the transform execution mode.

    .. seealso:: :class:`ExecutionMode`,
        :class:`neuraxle.base.DataContainer`,
        :class:`neuraxle.base.NonTransformableMixin`,
        :class:`neuraxle.base.NonFittableMixin`,
        :class:`neuraxle.base.MetaStepMixin`,
        :class:`neuraxle.base.BaseStep`
    """

    def __init__(self, wrapped: BaseStep):
        NonTransformableMixin.__init__(self)
        NonFittableMixin.__init__(self)
        MetaStepMixin.__init__(self, wrapped=wrapped)
github Neuraxio / Neuraxle / neuraxle / api / flask.py View on Github external
..
    Thanks to Umaneo Technologies Inc. for their contributions to this Machine Learning
    project, visit https://www.umaneo.com/ for more information on Umaneo Technologies Inc.

"""
from abc import ABC, abstractmethod

import numpy as np
from flask import Response

from neuraxle.base import BaseStep, NonFittableMixin
from neuraxle.pipeline import Pipeline


class JSONDataBodyDecoder(NonFittableMixin, BaseStep, ABC):
    """
    Class to be used within a FlaskRESTApiWrapper to convert input json to actual data (e.g.: arrays)
    """

    def transform(self, data_inputs):
        return self.decode(data_inputs)

    @abstractmethod
    def decode(self, data_inputs: dict):
        """
        Will convert data_inputs to a dict or a compatible data structure for jsonification

        :param encoded data_inputs (dict parsed from json):
        :return: data_inputs (as a data structure compatible with pipeline's data inputs)
        """
        raise NotImplementedError("TODO: inherit from the `JSONDataBodyDecoder` class and implement this method.")
github Neuraxio / Neuraxle / neuraxle / steps / loop.py View on Github external
def __init__(self, wrapped: BaseStep, copy_op=copy.deepcopy):
        BaseStep.__init__(self)
        MetaStepMixin.__init__(self, wrapped)
        self.set_step(wrapped)
        self.steps: List[BaseStep] = []
        self.copy_op = copy_op
github Neuraxio / Neuraxle / neuraxle / steps / numpy.py View on Github external
def __init__(self):
        BaseStep.__init__(self)
        NonFittableMixin.__init__(self)