neuraxle.steps.numpy

Pipeline Steps Based on NumPy

Those steps works with NumPy (np) arrays.

Classes

AddN([add])

Step to add a scalar to a numpy array.

MultiplyByN([multiply_by])

Step to multiply a numpy array.

NumpyConcatenateInnerFeatures()

Numpy concatenation step where the concatenation is performed along axis=-1.

NumpyConcatenateOnCustomAxis(axis)

Numpy concetenation step where the concatenation is performed along the specified custom axis.

NumpyConcatenateOuterBatch()

Numpy concetenation step where the concatenation is performed along axis=0.

NumpyFlattenDatum()

NumpyReshape(new_shape)

Reshape numpy array in data inputs.

NumpyShapePrinter(custom_message)

NumpyTranspose()

OneHotEncoder(nb_columns, name)

Step to one hot a set of columns.

Sum(axis)

Step sum numpy array using np.sum.

ToNumpy([cache_folder])

Convert data inputs, and expected outputs to a numpy array.

class neuraxle.steps.numpy.AddN(add=1)[source]

Step to add a scalar to a numpy array. Accepts an integer for the number to add to every data inputs.

Example usage:

pipeline = Pipeline([
    AddN(1)
])
outputs = pipeline.transform(np.array([1])
# outputs => np.array([2])
inverse_transform(data_inputs)[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

transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

class neuraxle.steps.numpy.MultiplyByN(multiply_by=1)[source]

Step to multiply a numpy array. Accepts an integer for the number to multiply by.

Example usage:

pipeline = Pipeline([
    MultiplyByN(3)
])
outputs = pipeline.transform(np.array([1])
# outputs => np.array([3])
inverse_transform(data_inputs)[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

transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

class neuraxle.steps.numpy.NumpyConcatenateInnerFeatures[source]

Numpy concatenation step where the concatenation is performed along axis=-1.

class neuraxle.steps.numpy.NumpyConcatenateOnCustomAxis(axis)[source]

Numpy concetenation step where the concatenation is performed along the specified custom axis.

transform(data_inputs)[source]

Apply the concatenation transformation along the specified axis. :param data_inputs: :return: Numpy array

class neuraxle.steps.numpy.NumpyConcatenateOuterBatch[source]

Numpy concetenation step where the concatenation is performed along axis=0.

class neuraxle.steps.numpy.NumpyFlattenDatum[source]
transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

class neuraxle.steps.numpy.NumpyReshape(new_shape)[source]

Reshape numpy array in data inputs.

import numpy as np
a = np.array([1,0,3])
outputs = NumpyReshape(shape=(-1,1)).transform(a)
assert np.array_equal(outputs, np.array([[1],[0],[3]]))

See also

NonFittableMixin BaseStep

transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

class neuraxle.steps.numpy.NumpyShapePrinter(custom_message: str = '')[source]
inverse_transform(processed_outputs)[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

transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

class neuraxle.steps.numpy.NumpyTranspose[source]
inverse_transform(data_inputs)[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

transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

class neuraxle.steps.numpy.OneHotEncoder(nb_columns, name)[source]

Step to one hot a set of columns. Accepts Integer Columns and converts it ot a one_hot. Rounds floats to integer for safety in the transform.

Example usage:

  1. Set up data

import numpy as np
a = np.array([1,0,3])
b = np.array([[0,1,0,0], [1,0,0,0], [0,0,0,1]])
  1. Do the actual conversion

from neuraxle.steps.numpy import OneHotEncoder
encoder = OneHotEncoder(nb_columns=4)
b_pred = encoder.transform(a)
  1. Assert it works

assert b_pred == b
transform(data_inputs)[source]

Transform data inputs using one hot encoding, adding no_columns to the -1 axis. :param data_inputs: data inputs to encode :return: one hot encoded data inputs

class neuraxle.steps.numpy.Sum(axis)[source]

Step sum numpy array using np.sum.

Example usage:

pipeline = Pipeline([
    Sum(axis=-1)
])

outputs = pipeline.transform(np.array([1, 2, 3])
# outputs => 6)

See also

NonFittableMixin, BaseStep

transform(data_inputs)[source]

Transform given data inputs.

Parameters

data_inputs – data inputs

Returns

transformed data inputs

class neuraxle.steps.numpy.ToNumpy(cache_folder=None)[source]

Convert data inputs, and expected outputs to a numpy array.