Inverse Transforms in Neuraxle: How to Reverse a Prediction

This demonstrates how to make a prediction, and then to undo the prediction to get back the original inputs or an estimate of the original inputs. Not every pipeline steps have an inverse transform method, because not every operation is reversible.

Out:

/home/gui/Documents/GIT/www.neuraxle.org-builder/docs/Neuraxle/neuraxle/logging/warnings.py:76: UserWarning: Argument `handler method=inverse_transform` for class `Pipeline` is deprecated. Please consider using `handle_inverse_transform` or the class `typing.Tuple[neuraxle.data_container.DataContainer, neuraxle.base.ExecutionContext]`
  warnings.warn(

import numpy as np

from neuraxle.pipeline import Pipeline
from neuraxle.steps.numpy import MultiplyByN


def main():
    p = Pipeline([MultiplyByN(multiply_by=2)])

    data_inputs = np.array([1, 2])
    generated_outputs = p.transform(data_inputs)
    regenerated_inputs = p.inverse_transform(generated_outputs)

    assert np.array_equal(regenerated_inputs, data_inputs)
    assert np.array_equal(generated_outputs, 2 * data_inputs)


if __name__ == "__main__":
    main()

Total running time of the script: ( 0 minutes 0.001 seconds)

Gallery generated by Sphinx-Gallery