neuraxle.steps.misc¶
Module-level documentation for neuraxle.steps.misc. Here is an inheritance diagram, including dependencies to other base modules of Neuraxle:
Miscelaneous Pipeline Steps¶
You can find here misc. pipeline steps, for example, callbacks useful for debugging, testing, and so forth.
Classes
|
Assert False upon _transform_data_container and _fit_data_container. |
|
Base class for callback steps. |
|
A step that calls a callback function for each of his methods : transform, fit, fit_transform, and even inverse_transform. |
|
Call a callback method on fit. |
|
|
|
|
This class’s purpose is to be sent to the callback to accumulate information. |
|
|
Call a callback method on transform and inverse transform. |
Examples using neuraxle.steps.misc.Sleep
¶
-
class
neuraxle.steps.misc.
AssertFalseStep
(message: str = 'This step should not fit nor transform.')[source]¶ Bases:
neuraxle.base.HandleOnlyMixin
,neuraxle.base.BaseStep
Assert False upon _transform_data_container and _fit_data_container.
-
__init__
(message: str = 'This step should not fit nor transform.')[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
_transform_data_container
(data_container, context)[source]¶ Transform data container.
- Parameters
data_container – data container
context – execution context
- Returns
data container
-
_fit_data_container
(data_container, context)[source]¶ Fit data container.
- Parameters
data_container – data container
context – execution context
- Returns
(fitted self, data container)
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
BaseCallbackStep
(callback_function, more_arguments: List[T] = (), hyperparams=None, fit_callback_function=None, transform_function=None)[source]¶ Bases:
neuraxle.base.BaseStep
,abc.ABC
Base class for callback steps.
-
__init__
(callback_function, more_arguments: List[T] = (), hyperparams=None, fit_callback_function=None, transform_function=None)[source]¶ Create the callback step with a function and extra arguments to send to the function
- Parameters
callback_function – The function that will be called on events.
more_arguments – Extra arguments that will be sent to the callback after the processed data (optional).
-
_fit_callback
(data_inputs, expected_outputs)[source]¶ Will call the self.fit_callback_function() with the data being processed and the extra arguments specified. It has no other effect.
- Parameters
data_inputs – data inputs to fit
expected_outputs – expected outputs to fit
- Returns
self
-
_callback
(data)[source]¶ Will call the self.callback_function() with the data being processed and the extra arguments specified. It has no other effect.
- Parameters
data_inputs – the data to process
- Returns
None
-
fit
(data_inputs, expected_outputs=None)[source]¶ Fit data inputs on the given expected outputs.
- Parameters
data_inputs – data inputs
expected_outputs – expected outputs to fit on.
- Returns
self
-
transform
(data_inputs)[source]¶ Transform given data inputs.
- Parameters
data_inputs – data inputs
- Returns
transformed data inputs
-
inverse_transform
(processed_outputs)[source]¶ Inverse Transform the given transformed data inputs.
p = Pipeline([MultiplyByN(2)]) _in = np.array([1, 2]) _out = p.transform(_in) _regenerated_in = p.inverse_transform(_out) assert np.array_equal(_regenerated_in, _in) assert np.array_equal(_out, _in * 2)
- Parameters
processed_outputs – processed data inputs
- Returns
inverse transformed processed outputs
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
FitCallbackStep
(callback_function, more_arguments: List[T] = (), hyperparams=None, fit_callback_function=None, transform_function=None)[source]¶ Bases:
neuraxle.steps.misc.BaseCallbackStep
Call a callback method on fit.
-
fit
(data_inputs, expected_outputs=None) → neuraxle.steps.misc.FitCallbackStep[source]¶ Will call the self._callback() with the data being processed and the extra arguments specified. Note that here, the data to process is packed into a tuple of (data_inputs, expected_outputs). It has no other effect.
- Parameters
data_inputs – the data to process
expected_outputs – the data to process
- Returns
self
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
TransformCallbackStep
(callback_function, more_arguments: List[T] = (), hyperparams=None, fit_callback_function=None, transform_function=None)[source]¶ Bases:
neuraxle.steps.misc.BaseCallbackStep
Call a callback method on transform and inverse transform.
-
fit_transform
(data_inputs, expected_outputs=None) → Tuple[neuraxle.base.BaseStep, Any][source]¶ Fit, and transform step with the given data inputs, and expected outputs.
- Parameters
data_inputs – data inputs
expected_outputs – expected outputs to fit on
- Returns
(fitted self, tranformed data inputs)
-
transform
(data_inputs)[source]¶ Will call the self._callback() with the data being processed and the extra arguments specified. It has no other effect.
- Parameters
data_inputs – the data to process
- Returns
the same data as input, unchanged (like the Identity class).
-
inverse_transform
(processed_outputs)[source]¶ Will call the self._callback() with the data being processed and the extra arguments specified. It has no other effect.
- Parameters
processed_outputs – the data to process
- Returns
the same data as input, unchanged (like the Identity class).
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
FitTransformCallbackStep
(transform_callback_function=None, fit_callback_function=None, more_arguments: List[T] = (), transform_function=None, hyperparams=None)[source]¶ Bases:
neuraxle.base.BaseStep
-
__init__
(transform_callback_function=None, fit_callback_function=None, more_arguments: List[T] = (), transform_function=None, hyperparams=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(data_inputs, expected_outputs=None)[source]¶ Fit data inputs on the given expected outputs.
- Parameters
data_inputs – data inputs
expected_outputs – expected outputs to fit on.
- Returns
self
-
transform
(data_inputs)[source]¶ Transform given data inputs.
- Parameters
data_inputs – data inputs
- Returns
transformed data inputs
-
fit_transform
(data_inputs, expected_outputs=None) → Tuple[neuraxle.base.BaseStep, Any][source]¶ Fit, and transform step with the given data inputs, and expected outputs.
- Parameters
data_inputs – data inputs
expected_outputs – expected outputs to fit on
- Returns
(fitted self, tranformed data inputs)
-
inverse_transform
(processed_outputs)[source]¶ Inverse Transform the given transformed data inputs.
p = Pipeline([MultiplyByN(2)]) _in = np.array([1, 2]) _out = p.transform(_in) _regenerated_in = p.inverse_transform(_out) assert np.array_equal(_regenerated_in, _in) assert np.array_equal(_out, _in * 2)
- Parameters
processed_outputs – processed data inputs
- Returns
inverse transformed processed outputs
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
CallbackWrapper
(wrapped, transform_callback_function, fit_callback_function, inverse_transform_callback_function=None, more_arguments: List[T] = (), hyperparams=None)[source]¶ Bases:
neuraxle.base.HandleOnlyMixin
,neuraxle.base.MetaStep
A step that calls a callback function for each of his methods : transform, fit, fit_transform, and even inverse_transform. To be used with
TapeCallbackFunction
.tape_fit = TapeCallbackFunction() tape_transform = TapeCallbackFunction() tape_inverse_transform = TapeCallbackFunction() callback_wrapper = CallbackWrapper(MultiplyByN(2), tape_transform_preprocessing, tape_fit_preprocessing, tape_inverse_transform_preprocessing)
See also
-
__init__
(wrapped, transform_callback_function, fit_callback_function, inverse_transform_callback_function=None, more_arguments: List[T] = (), hyperparams=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
_fit_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → Tuple[neuraxle.base.BaseStep, neuraxle.data_container.DataContainer][source]¶ - Parameters
data_container (DataContainer) – data container
context (ExecutionContext) – execution context
- Returns
step, data_container
-
_fit_transform_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → Tuple[neuraxle.base.BaseStep, neuraxle.data_container.DataContainer][source]¶ - Parameters
data_container (DataContainer) – data container
context (ExecutionContext) – execution context
- Returns
step, data_container
-
_transform_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.data_container.DataContainer[source]¶ - Return type
- Parameters
data_container (DataContainer) – data container
context (ExecutionContext) – execution context
- Returns
step, data_container
- Type
-
handle_inverse_transform
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.data_container.DataContainer[source]¶ - Parameters
context (ExecutionContext) – execution context
data_container (DataContainer) – data containerj
- Returns
data container
- Return type
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
TapeCallbackFunction
[source]¶ Bases:
object
This class’s purpose is to be sent to the callback to accumulate information.
Example usage:
expected_tape = ["1", "2", "3", "a", "b", "4"] tape = TapeCallbackFunction() p = Pipeline([ Identity(), TransformCallbackStep(tape.callback, ["1"]), TransformCallbackStep(tape.callback, ["2"]), TransformCallbackStep(tape.callback, ["3"]), AddFeatures([ TransformCallbackStep(tape.callback, ["a"]), TransformCallbackStep(tape.callback, ["b"]), ]), TransformCallbackStep(tape.callback, ["4"]), Identity() ]) p.fit_transform(np.ones((1, 1))) assert expected_tape == tape.get_name_tape()
-
class
neuraxle.steps.misc.
HandleCallbackStep
(handle_fit_callback, handle_transform_callback, handle_fit_transform_callback)[source]¶ Bases:
neuraxle.base.ForceHandleOnlyMixin
,neuraxle.base.BaseStep
-
__init__
(handle_fit_callback, handle_transform_callback, handle_fit_transform_callback)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
_fit_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → Tuple[neuraxle.base.BaseStep, neuraxle.data_container.DataContainer][source]¶ Fit data container.
- Parameters
data_container (
DataContainer
) – data containercontext (
ExecutionContext
) – execution context
- Returns
(fitted self, data container)
-
_transform_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.data_container.DataContainer[source]¶ Transform data container.
- Return type
- Parameters
data_container (
DataContainer
) – data containercontext (
ExecutionContext
) – execution context
- Returns
data container
-
_fit_transform_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → Tuple[neuraxle.base.BaseStep, neuraxle.data_container.DataContainer][source]¶ Fit and transform data container with the given execution context. Will do:
data_container, context = self._fit_data_container(data_container, context) data_container = self._transform_data_container(data_container, context) return self, data_container
- Parameters
data_container (
DataContainer
) – data containercontext (
ExecutionContext
) – execution context
- Returns
transformed data container
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
Sleep
(sleep_time: float = 0.1, add_random_quantity: float = 0.0)[source]¶ Bases:
neuraxle.base.BaseTransformer
-
__init__
(sleep_time: float = 0.1, add_random_quantity: float = 0.0)[source]¶ Sleep for a given time, given in seconds.
-
transform
(data_inputs)[source]¶ Transform given data inputs.
- Parameters
data_inputs – data inputs
- Returns
transformed data inputs
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
FitTransformCounterLoggingStep
[source]¶ Bases:
neuraxle.base.HandleOnlyMixin
,neuraxle.base.BaseStep
-
_fit_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.base.BaseStep[source]¶ Fit data container.
- Return type
- Parameters
data_container (
DataContainer
) – data containercontext (
ExecutionContext
) – execution context
- Returns
(fitted self, data container)
-
_transform_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.data_container.DataContainer[source]¶ Transform data container.
- Return type
- Parameters
data_container (
DataContainer
) – data containercontext (
ExecutionContext
) – execution context
- Returns
data container
-
_fit_transform_data_container
(data_container: neuraxle.data_container.DataContainer, context: neuraxle.base.ExecutionContext) → neuraxle.data_container.DataContainer[source]¶ Fit and transform data container with the given execution context. Will do:
data_container, context = self._fit_data_container(data_container, context) data_container = self._transform_data_container(data_container, context) return self, data_container
- Return type
- Parameters
data_container (
DataContainer
) – data containercontext (
ExecutionContext
) – execution context
- Returns
transformed data container
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.steps.misc.
TransformOnlyCounterLoggingStep
[source]¶ Bases:
neuraxle.base.NonFittableMixin
,neuraxle.steps.misc.FitTransformCounterLoggingStep
-
_abc_impl
= <_abc_data object>¶
-