Transformation

Implementation of various normalizers for time series data.

class ecgan.utils.transformation.DataTransformation[source]

Bases: abc.ABC

A base class for transformations to inherit from.

fit(data)[source]

Fit a transformation on a numpy array of data points.

Return type

None

transform(data)[source]

Apply a transformation on a numpy array of data points.

Requires an already fitted transformation.

Return type

Tensor

Returns

Transformed data.

fit_transform(data)[source]

First apply the fit and then perform the transformation on given data.

The 2D case as well as the 3D case are transformed along the columns. In 2D this is useful for a typical feature matrix but not often useful for time series data where one might want to transform along the rows or the whole dataset. If you want to transform time series data, one way would be to use 3D transformation with shape (samples x sequence_length x 1).

Return type

Tensor

class ecgan.utils.transformation.MinMaxTransformation[source]

Bases: ecgan.utils.transformation.DataTransformation

Min-Max normalizer: scales the input to [0,1].

get_params()[source]

Retrieve normalization parameters.

Return type

Dict

set_params(params)[source]

Set existing normalization parameters.

Return type

None

class ecgan.utils.transformation.StandardizationTransformation[source]

Bases: ecgan.utils.transformation.DataTransformation

Standardize the data such that it is distributed to N(0,1).

class ecgan.utils.transformation.WhiteningTransformation(fudge=1e-16)[source]

Bases: ecgan.utils.transformation.DataTransformation

Apply a Whitening transformation on data.

The Whitening transformation returns decorrelated data i.e. data with unit covariance matrix.

class ecgan.utils.transformation.FFTTransformation[source]

Bases: ecgan.utils.transformation.DataTransformation

Compute the 2D or 3D discrete Fourier transform using the PyTorch FFT implementation.

class ecgan.utils.transformation.SamplewiseMinmaxTransformation[source]

Bases: ecgan.utils.transformation.DataTransformation

Scales each sample to the [0, 1] range.

MinMaxTransformation scales in the same way but per channel, not per sample.

static transform_1d(sample)[source]

Scale individual series to 0 and 1.

class ecgan.utils.transformation.NoTransformation[source]

Bases: ecgan.utils.transformation.DataTransformation

Apply no transformation.

ecgan.utils.transformation.get_transformation(transformation)[source]

Transform the data. The output range depends on the normalizer chosen.

Return type

DataTransformation