uadapy.dr.uapca module

uadapy.dr.uapca.compute_ua_cov(means: ndarray, covs: ndarray, weights: ndarray = None) ndarray

Computes the weighted uncertainty-aware covariance matrix. If weights is None, uniform weights are assumed.

Parameters:
  • means (np.ndarray) – Array of mean vectors.

  • covs (np.ndarray) – Array of covariance matrices.

  • weights (np.ndarray, optional) – Array of weights of shape (n,).

Returns:

Weighted uncertainty-aware covariance matrix.

Return type:

np.ndarray

uadapy.dr.uapca.compute_uapca(means: ndarray, covs: ndarray, weights: ndarray = None) tuple[ndarray, ndarray]

Computes the principal components for uncertainty-aware PCA.

Parameters:
  • means (np.ndarray) – Array of mean vectors.

  • covs (np.ndarray) – Array of covariance matrices.

  • weights (np.ndarray, optional) – Array of weights for each distribution.

Returns:

Eigenvectors and eigenvalues.

Return type:

tuple[np.ndarray, np.ndarray]

uadapy.dr.uapca.transform_uapca(means, covs, dims: int = 2, weights: ndarray = None) tuple[ndarray, ndarray]

Projects mean and covariance matrices into a lower-dimensional space.

Parameters:
  • means (np.ndarray) – Array of mean vectors.

  • covs (np.ndarray) – Array of covariance matrices.

  • dims (int) – Target dimension for projection.

  • weights (np.ndarray, optional) – Array of weights for each distribution.

Returns:

Projected mean vectors and covariance matrices.

Return type:

tuple[np.ndarray, np.ndarray]

uadapy.dr.uapca.uapca(distributions, n_dims: int = 2, weights: ndarray = None)

Applies UAPCA algorithm to the distribution and returns the distribution in lower-dimensional space. It assumes a normal distribution. If you apply other distributions that provide mean and covariance, these values would be used to approximate a normal distribution.

Parameters:
  • distributions (list) – List of input distributions

  • n_dims (int) – Target dimension. Default is 2.

  • weights (np.ndarray, optional) – Array of weights for each distribution. If None, uniform weights are used.

Returns:

List of distributions in low-dimensional space.

Return type:

list