neuraxle.steps.loop

Pipeline Steps For Looping

Classes

FlattenForEach(wrapped, then_unflatten)

Step that reduces a dimension instead of manually looping on it.

ForEachDataInput(wrapped[, …])

Truncable step that fits/transforms each step for each of the data inputs, and expected outputs.

StepClonerForEachDataInput(wrapped[, …])

class neuraxle.steps.loop.FlattenForEach(wrapped: neuraxle.base.BaseStep, then_unflatten: bool = True)[source]

Step that reduces a dimension instead of manually looping on it.

should_resume(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext)[source]

Returns True if a step can be resumed with the given the data container, and execution context. See Checkpoint class documentation for more details on how a resumable checkpoint works.

Parameters
  • data_container – data container to resume from

  • context – execution context to resume from

Returns

if we can resume

class neuraxle.steps.loop.ForEachDataInput(wrapped: neuraxle.base.BaseStep, cache_folder_when_no_handle=None)[source]

Truncable step that fits/transforms each step for each of the data inputs, and expected outputs.

hash_data_container(data_container)[source]

Hash data container using self.hashers.

  1. Hash current ids with hyperparams.

  2. Hash summary id with hyperparams.

Parameters

data_container – the data container to transform

Returns

transformed data container

should_resume(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext)[source]

Returns True if a step can be resumed with the given the data container, and execution context. See Checkpoint class documentation for more details on how a resumable checkpoint works.

Parameters
  • data_container – data container to resume from

  • context – execution context to resume from

Returns

if we can resume

class neuraxle.steps.loop.StepClonerForEachDataInput(wrapped: neuraxle.base.BaseStep, copy_op=<function deepcopy>, cache_folder_when_no_handle=None)[source]
inverse_transform(data_output)[source]

Inverse Transform the given transformed data inputs.

mutate() or reverse() can be called to change the default transform behavior :

p = Pipeline([MultiplyBy()])

_in = np.array([1, 2])

_out = p.transform(_in)

_regenerated_in = reversed(p).transform(_out)

assert np.array_equal(_regenerated_in, _in)
Parameters

processed_outputs – processed data inputs

Returns

inverse transformed processed outputs

set_hyperparams(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples) → neuraxle.base.BaseStep[source]

Set step hyperparameters, and wrapped step hyperparams with the given hyperparams.

Example :

step.set_hyperparams(HyperparameterSamples({
    'learning_rate': 0.10
    'wrapped__learning_rate': 0.10 # this will set the wrapped step 'learning_rate' hyperparam
}))
Parameters

hyperparams – hyperparameters

Returns

self

set_hyperparams_space(hyperparams_space: neuraxle.hyperparams.space.HyperparameterSpace) → neuraxle.base.BaseStep[source]

Set meta step and wrapped step hyperparams space using the given hyperparams space.

Parameters

hyperparams_space – ordered dict containing all hyperparameter spaces

Returns

self

set_train(is_train: bool = True)[source]

Set pipeline step mode to train or test. Also set wrapped step mode to train or test.

For instance, you can add a simple if statement to direct to the right implementation:

def transform(self, data_inputs):
    if self.is_train:
        self.transform_train_(data_inputs)
    else:
        self.transform_test_(data_inputs)

def fit_transform(self, data_inputs, expected_outputs=None):
    if self.is_train:
        self.fit_transform_train_(data_inputs, expected_outputs)
    else:
        self.fit_transform_test_(data_inputs, expected_outputs)
Parameters

is_train – bool

Returns

update_hyperparams(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples) → neuraxle.base.BaseStep[source]

Update the step hyperparameters without removing the already-set hyperparameters. Please refer to update_hyperparams().

Parameters

hyperparams (HyperparameterSamples) – hyperparams to update

Returns

self

Return type

BaseStep

See also

update_hyperparams(), HyperparameterSamples