eulerpi.core.data_transformation module

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

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

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 DataNormalizer(normalizing_matrix: Array | None = None, mean_vector: Array | None = None)[source]

Bases: DataTransformation

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.

classmethod from_data(data: Array) DataTransformation[source]

Initialize a DataTransformation object by calculating the mean vector and normalizing matrix from the given data.

Parameters:

data (jnp.ndarray) – The data from which to calculate the mean vector and normalizing matrix.

Returns:

The initialized DataTransformation object.

Return type:

DataTransformation

classmethod from_transformation(mean_vector: Array, normalizing_matrix: Array) DataTransformation[source]

Initialize a DataTransformation object from the given mean vector, normalizing matrix and determinant.

Parameters:
  • mean_vector (jnp.ndarray) – The vector to shift the data by.

  • normalizing_matrix (jnp.ndarray) – The matrix to multiply the data by.

Returns:

The initialized DataTransformation object.

Return type:

DataTransformation

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 DataPCA(pca: PCA | None = None)[source]

Bases: DataTransformation

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

classmethod from_data(data: Array, n_components: int | None = None) DataTransformation[source]

Initialize a DataPCA object by calculating the PCA from the given data.

Parameters:
  • data (jnp.ndarray) – The data to be used for the PCA.

  • n_components (Optional[int], optional) – The number of components to keep. If None is passed, min(n_samples,n_features) is used. Defaults to None.

Returns:

The initialized DataPCA object.

Return type:

DataTransformation

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