How to use the neuraxle.base.NonFittableMixin 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
class SomeTruncableStep(TruncableSteps):
    def __init__(self):
        TruncableSteps.__init__(self,
                                hyperparams=HYPERPARAMETERS,
                                hyperparams_space=HYPERPARAMETERS_SPACE,
                                steps_as_tuple=(SomeStepWithHyperparams(), SomeStepWithHyperparams())
                                )

    def transform(self, data_inputs):
        pass

    def fit(self, data_inputs, expected_outputs=None):
        pass


class SomeSplitStep(NonFittableMixin, BaseStep):
    def fit(self, data_inputs, expected_outputs=None) -> 'NonFittableMixin':
        pass

    def fit_transform(self, data_inputs, expected_outputs=None):
        pass

    def transform(self, data_inputs):
        pass
github Neuraxio / Neuraxle / testing / test_metastep_mixin.py View on Github external
from neuraxle.pipeline import Pipeline

from neuraxle.base import MetaStepMixin, BaseStep, NonFittableMixin, NonTransformableMixin
from neuraxle.union import Identity


class SomeMetaStep(NonFittableMixin, MetaStepMixin, BaseStep):
    def __init__(self, wrapped: BaseStep):
        BaseStep.__init__(self)
        MetaStepMixin.__init__(self, wrapped)

    def transform(self, data_inputs):
        self.wrapped.transform(data_inputs)


def test_metastepmixin_set_train_should_set_train_to_false():
    p = SomeMetaStep(Pipeline([
        Identity()
    ]))

    p.set_train(False)

    assert not p.is_train
github Neuraxio / Neuraxle / testing / test_pickle_checkpoint_step.py View on Github external
from neuraxle.base import NonFittableMixin
from neuraxle.checkpoints import DefaultCheckpoint
from neuraxle.data_container import DataContainer
from neuraxle.hyperparams.space import HyperparameterSamples
from neuraxle.pipeline import ResumablePipeline
from neuraxle.steps.misc import TapeCallbackFunction, TransformCallbackStep, BaseCallbackStep
from testing.steps.test_output_transformer_wrapper import MultiplyBy2OutputTransformer

EXPECTED_TAPE_AFTER_CHECKPOINT = ["2", "3"]

data_inputs = np.array([1, 2])
expected_outputs = np.array([2, 3])
expected_rehashed_data_inputs = ['44f9d6dd8b6ccae571ca04525c3eaffa', '898a67b2f5eeae6393ca4b3162ba8e3d']


class DifferentCallbackStep(NonFittableMixin, BaseCallbackStep):
    def transform(self, data_inputs):
        self._callback(data_inputs)
        return data_inputs


def create_pipeline(tmpdir, pickle_checkpoint_step, tape, hyperparameters=None, different=False, save_pipeline=True):
    if different:
        pipeline = ResumablePipeline(
            steps=[
                ('a',
                 DifferentCallbackStep(tape.callback, ["1"], hyperparams=hyperparameters)),
                ('pickle_checkpoint', pickle_checkpoint_step),
                ('c', TransformCallbackStep(tape.callback, ["2"])),
                ('d', TransformCallbackStep(tape.callback, ["3"]))
            ],
            cache_folder=tmpdir
github Neuraxio / Neuraxle / neuraxle / steps / data.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.

"""
import random
from typing import Iterable

from neuraxle.base import BaseStep, MetaStepMixin, NonFittableMixin, ExecutionContext
from neuraxle.data_container import DataContainer
from neuraxle.steps.output_handlers import InputAndOutputTransformerMixin


class DataShuffler(NonFittableMixin, InputAndOutputTransformerMixin, BaseStep):
    """
    Data Shuffling step that shuffles data inputs, and expected_outputs at the same time.

    .. code-block:: python

        p = Pipeline([
            TrainOnlyWrapper(DataShuffler(seed=42, increment_seed_after_each_fit=True, increment_seed_after_each_fit=False)),
            EpochRepeater(ForecastingPipeline(), epochs=EPOCHS, repeat_in_test_mode=False)
        ])

    .. warning::
        You probably always want to wrap this step by a :class:`TrainOnlyWrapper`

    .. seealso::
        :class:`EpochRepeater`,
        :class:`TrainOnlyWrapper`,
github Neuraxio / Neuraxle / examples / non_fittable_mixin.py View on Github external
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.

"""
import numpy as np

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


class NonFittableStep(NonFittableMixin, BaseStep):
    """
    Fit method is automatically implemented as changing nothing.
    Please make your steps inherit from NonFittableMixin, when they don't need any transformations.
    Also, make sure that BaseStep is the last step you inherit from.
    """

    def transform(self, data_inputs):
        # insert your transform code here
        print("NonFittableStep: I transformed.")
        return self, data_inputs

    def inverse_transform(self, processed_outputs):
        # insert your inverse transform code here
        print("NonFittableStep: I inverse transformed.")
        return processed_outputs
github Neuraxio / Neuraxle / neuraxle / steps / numpy.py View on Github external
def __init__(self):
        BaseStep.__init__(self)
        NonFittableMixin.__init__(self)
github Neuraxio / Neuraxle / neuraxle / steps / numpy.py View on Github external
import numpy as np

from neuraxle.base import NonFittableMixin, BaseStep, DataContainer
from neuraxle.hyperparams.space import HyperparameterSamples


class NumpyFlattenDatum(NonFittableMixin, BaseStep):
    def __init__(self):
        BaseStep.__init__(self)
        NonFittableMixin.__init__(self)

    def transform(self, data_inputs):
        return data_inputs.reshape(data_inputs.shape[0], -1)


class NumpyConcatenateOnCustomAxis(NonFittableMixin, BaseStep):
    """
    Numpy concetenation step where the concatenation is performed along the specified custom axis.
    """

    def __init__(self, axis):
        """
        Create a numpy concatenate on custom axis object.
        :param axis: the axis where the concatenation is performed.
        :return: NumpyConcatenateOnCustomAxis instance.
        """
        self.axis = axis
        BaseStep.__init__(self)
        NonFittableMixin.__init__(self)

    def _transform_data_container(self, data_container, context):
        """
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)