eulerpi.core.data_transformations module

Data transformations can be used to improve the performance of the inference function by improving the quality of the kernel density estimate.

This subpackage contains all predefined data transformations and an abstract base class for custom data transformations.

class AffineTransformation(A: Array, b: Array)[source]

Bases: DataTransformation

Class for applying an affine data transformation, y=Ax+b

jacobian(data: Array) Array[source]

Calculate the jacobian of the transformation at the given data point(s).

Parameters:

data (jnp.ndarray) – The data at which the jacobian should be evaluated.

Raises:

NotImplementedError – Raised if the jacobian is not implemented in the subclass.

Returns:

The jacobian of the transformation at the given data point(s).

Return type:

jnp.ndarray

transform(data: float64 | Array) float64 | Array[source]

Normalize the given data.

Parameters:

data (Union[jnp.double, jnp.ndarray]) – The data to be normalized. Columns correspond to different dimensions. Rows correspond to different observations.

Returns:

The normalized data.

Return type:

Union[jnp.double, jnp.ndarray]

class DataIdentity[source]

Bases: DataTransformation

The identity transformation. Does not change the data.

jacobian(data: Array) Array[source]

Returns the identity matrix.

Parameters:

data (jnp.ndarray) – The data at which the jacobian should be evaluated.

Returns:

The identity matrix.

Return type:

jnp.ndarray

transform(data: Array) Array[source]

Returns the data unchanged.

Parameters:

data (jnp.ndarray) – The data which should be transformed.

Returns:

The data unchanged.

Return type:

jnp.ndarray

class DataNormalization(data: Array)[source]

Bases: AffineTransformation

Class for normalizing data. The data is normalized by subtracting the mean and multiplying by the inverse of the Cholesky decomposition of the covariance matrix.

class DataPCA(data: Array, n_components: int | str)[source]

Bases: DataTransformation

The DataPCA class can be used to transform the data using the Principal Component Analysis.

jacobian(data: Array) Array[source]

Return the jacobian of the pca transformation at the given data point(s).

Parameters:

data (jnp.ndarray) – The data point(s) at which the jacobian should be evaluated.

Returns:

The jacobian of the pca transformation at the given data point(s).

Return type:

jnp.ndarray

transform(data: Array) Array[source]

Transform the given data using the PCA.

Parameters:

data (jnp.ndarray) – The data to be transformed.

Returns:

The data projected onto and expressed in the basis of the principal components.

Return type:

jnp.ndarray

class DataTransformation[source]

Bases: ABC

Abstract base class for all data transformations

Data transformations can be used to improve the performance of the inference function by improving the quality of the kernel density estimate.

abstract jacobian(data: Array) Array[source]

Calculate the jacobian of the transformation at the given data point(s).

Parameters:

data (jnp.ndarray) – The data at which the jacobian should be evaluated.

Raises:

NotImplementedError – Raised if the jacobian is not implemented in the subclass.

Returns:

The jacobian of the transformation at the given data point(s).

Return type:

jnp.ndarray

abstract transform(data: Array) Array[source]

Transform the given data point(s)

Parameters:

data (jnp.ndarray) – The data to be transformed. Columns correspond to different dimensions. Rows correspond to different observations.

Raises:

NotImplementedError – Raised if the transform is not implemented in the subclass.

Returns:

The transformed data point(s).

Return type:

jnp.ndarray