apca.models

AugmentedPCA models class references and descriptions.

Supervised AugmentedPCA

class apca.models.SAPCA(n_components=None, mu=1.0, inference='encoded', decomp='approx', pow_iter=5, n_oversamp=5, diag_const=1e-08, random_state=None)

Supervised AugmentedPCA (sAPCA) model class. The objective of the sAPCA model is to find components that 1) represent the maximum variance expressed in the primary data (primary objective) and 2) represent the variance expressed in the data labels or outcome data (augmenting objective).

Parameters:
n_componentsint; optional, default is None

Number of components. If None reduce to minimum dimension of primary data.

mufloat; optional, default is 1.0

Supervision strength.

inferencestr; optional, default is ‘encoded’

Model inference strategy.

decompstr; optional, default is ‘approx’

Decomposition approach.

pow_iterint; optional, default is 5

Number of power iterations to perform in randomized approximation.

n_oversampint; optional, default is 5

Oversampling parameter for randomized approximation.

diag_constfloat; optional, default is 1e-8

Constant added to diagonals of matrix prior to inversion.

random_stateint

Model random state. Ignored if exact eigenvalue decomposition approach used.

Attributes:
n_componentsint

Number of components. If None then reduce to minimum dimension of primary data.

mufloat

Supervision strength.

pow_iterint

Number of power iterations to perform in randomized approximation.

n_oversampint

Oversampling parameter for randomized approximation.

diag_constfloat

Constant added to diagonals of matrix prior to inversion.

random_stateint

Model random state. Ignored if exact eigenvalue decomposition approach used.

mean_X_numpy.ndarray

1-dimensional (p,) mean array of primary data matrix.

mean_Y_numpy.ndarray

1-dimensional (q,) mean array of primary data matrix.

mean_Z_numpy.ndarray

1-dimensional (p + q,) mean array of combined primary and supervised data matrices.

B_numpy.ndarray

2-dimensional decomposition matrix.

W_numpy.ndarray

2-dimensional primary data loadings matrix.

D_numpy.ndarray

2-dimensional supervised data loadings matrix.

A_numpy.ndarray

2-dimensional encoding matrix. None if inference is set to ‘local’.

eigvals_numpy.ndarray

1-dimensional array of sorted decomposition matrix eigenvalues.

is_fitted_bool

Indicates whether model has been fitted.

Methods

fit(X, Y)

Fits AugmentedPCA model to data.

transform(X, Y)

Transforms data into scores using AugmentedPCA model formulation.

fit_transform(X, Y)

Fits AugumentedPCA model to data and transforms data into scores.

reconstruct(X, Y)

Reconstructs primary and supervised data.

get_components()

Returns primary data loadings / components. Alias for get_W().

get_W()

Returns primary data loadings.

get_D()

Returns supervised data loadings.

get_A()

Returns encoding matrix.

get_eigvals()

Returns 1-dimensional array of sorted decomposition matrix eigenvalues.

fit(X: ndarray, Y: ndarray | tuple | list)

Fits AugmentedPCA model to data.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices.

fit_transform(X: ndarray, Y: ndarray | tuple | list) ndarray

Fits AugumentedPCA model to data and transforms data into scores.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices.

Returns:
Snumpy.ndarray

2-dimensional (n x k) scores matrix.

get_A() ndarray

Returns encoding matrix.

Parameters:
none
Returns:
self.A_.copy()numpy.ndarray

2-dimensional (d x p) encoding matrix.

get_D() ndarray

Returns supervised data loadings.

Parameters:
none
Returns:
self.D_.copy()numpy.ndarray

2-dimensional (q x k) supervised data loadings matrix.

get_W() ndarray

Returns primary data loadings.

Parameters:
none
Returns:
self.W_.copy()numpy.ndarray

2-dimensional (p x k) primary data loadings matrix.

get_components() ndarray

Returns primary data loadings / components.

Parameters:
none
Returns:
self.W_.copy()numpy.ndarray

2-dimensional (p x k) primary data loadings matrix.

get_eigvals() ndarray

Returns 1-dimensional array of sorted decomposition matrix eigenvalues.

Parameters:
none
Returns:
self.eigvals_.copy()numpy.ndarray

1-dimensional array of sorted eigenvalues.

reconstruct(X: ndarray, Y: ndarray | tuple | list) ndarray

Reconstruct primary and augmenting data.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices. Ignored if inference is set to ‘encoded’.

Returns:
X_reconnumpy.ndarray

2-dimensional (n x p) reconstruction of primary data.

Y_reconnumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) reconstruction of augmenting data or tuple of 2-dimensional (n x qs), (n x qa) augmenting data reconstructions.

transform(X: ndarray, Y: ndarray | tuple | list) ndarray

Transforms data into scores using AugmentedPCA model formulation.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices. Ignored if inference is set to ‘encoded’.

Returns:
Snumpy.ndarray

2-dimensional (n x k) scores matrix.

Adversarial AugmentedPCA

class apca.models.AAPCA(n_components=None, mu=1.0, inference='encoded', decomp='approx', pow_iter=5, n_oversamp=5, diag_const=1e-08, random_state=None)

Adversarial AugmentedPCA (aAPCA) model class. The objective of the aAPCA model is to find components that 1) represent the maximum variance expressed in the primary data (primary objective) while 2) maintaining a degree of invariance to a set of concomitant data (augmenting objective).

Parameters:
n_componentsint; optional, default is None

Number of components. If None then reduce to minimum dimension of primary data.

mufloat; optional, default is 1.0

Adversary strength.

inferencestr; optional, default is ‘encoded’

Model inference strategy.

decompstr; optional, default is ‘approx’

Decomposition approach.

pow_iterint; optional, default is 5

Number of power iterations to perform in randomized AugmentedPCA approximation.

n_oversampint; optional, default is 5

Oversampling parameter for randomized AugmentedPCA approximations.

diag_constfloat; optional, default is 1e-8

Constant added to diagonals of matrix prior to inversion.

random_stateint

Model random state. Ignored if exact eigenvalue decomposition approach used.

Attributes:
n_componentsint

Number of components. If None then reduce to minimum dimension of primary data.

mufloat

Adversary strength.

pow_iterint

Number of power iterations to perform in randomized approximation.

n_oversampint

Oversampling parameter for randomized approximation.

diag_constfloat

Constant added to diagonals of matrix prior to inversion.

random_stateint

Model random state. Ignored if exact eigenvalue decomposition approach used.

mean_X_numpy.ndarray

1-dimensional (p,) mean array of primary data matrix.

mean_Y_numpy.ndarray

1-dimensional (q,) mean array of primary data matrix.

mean_Z_numpy.ndarray

1-dimensional (p + q,) mean array of combined primary and concomitant data matrices.

B_numpy.ndarray

2-dimensional decomposition matrix.

W_numpy.ndarray

2-dimensional primary data loadings matrix.

D_numpy.ndarray

2-dimensional concomitant data loadings matrix.

A_numpy.ndarray

2-dimensional encoding matrix. None if inference is set to ‘local’.

eigvals_numpy.ndarray

1-dimensional array of sorted decomposition matrix eigenvalues.

is_fitted_bool

Indicates whether model has been fitted.

Methods

fit(X, Y)

Fits AugmentedPCA model to data.

transform(X, Y)

Transforms data into scores using AugmentedPCA model formulation.

fit_transform(X, Y)

Fits AugumentedPCA model to data and transforms data into scores.

reconstruct(X, Y)

Reconstructs primary and concomitant data.

get_components()

Returns primary data loadings / components. Alias for get_W().

get_W()

Returns primary data loadings.

get_D()

Returns concomitant data loadings.

get_A()

Returns encoding matrix.

get_eigvals()

Returns 1-dimensional array of sorted decomposition matrix eigenvalues.

fit(X: ndarray, Y: ndarray | tuple | list)

Fits AugmentedPCA model to data.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices.

fit_transform(X: ndarray, Y: ndarray | tuple | list) ndarray

Fits AugumentedPCA model to data and transforms data into scores.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices.

Returns:
Snumpy.ndarray

2-dimensional (n x k) scores matrix.

get_A() ndarray

Returns encoding matrix.

Parameters:
none
Returns:
self.A_.copy()numpy.ndarray

2-dimensional (d x p) encoding matrix.

get_D() ndarray

Returns concomitant data loadings.

Parameters:
none
Returns:
self.D_.copy()numpy.ndarray

2-dimensional (q x k) concomitant data loadings matrix.

get_W() ndarray

Returns primary data loadings.

Parameters:
none
Returns:
self.W_.copy()numpy.ndarray

2-dimensional (p x k) primary data loadings matrix.

get_components() ndarray

Returns primary data loadings / components.

Parameters:
none
Returns:
self.W_.copy()numpy.ndarray

2-dimensional (p x k) primary data loadings matrix.

get_eigvals() ndarray

Returns 1-dimensional array of sorted decomposition matrix eigenvalues.

Parameters:
none
Returns:
self.eigvals_.copy()numpy.ndarray

1-dimensional array of sorted eigenvalues.

reconstruct(X: ndarray, Y: ndarray | tuple | list) ndarray

Reconstruct primary and augmenting data.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices. Ignored if inference is set to ‘encoded’.

Returns:
X_reconnumpy.ndarray

2-dimensional (n x p) reconstruction of primary data.

Y_reconnumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) reconstruction of augmenting data or tuple of 2-dimensional (n x qs), (n x qa) augmenting data reconstructions.

transform(X: ndarray, Y: ndarray | tuple | list) ndarray

Transforms data into scores using AugmentedPCA model formulation.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices. Ignored if inference is set to ‘encoded’.

Returns:
Snumpy.ndarray

2-dimensional (n x k) scores matrix.

Combined AugmentedPCA

class apca.models.CAPCA(n_components=None, mu=1.0, inference='encoded', decomp='approx', pow_iter=5, n_oversamp=5, diag_const=1e-08, random_state=None)

Combined AugmentedPCA (cAPCA) model class. The objective of the cAPCA model is to find components that 1) represent the maximum variance expressed in the primary data (primary objective) and 2) represent the variance expressed in the data labels or outcome data and maintain a degree of invariance to a set of concomitant data (augmenting objectives).

Parameters:
n_componentsint; optional, default is None

Number of components. If None reduce to minimum dimension of primary data.

mufloat or tuple or list; optional, default is 1.0

Augmenting objective strength(s).

inferencestr; optional, default is ‘encoded’

Model inference strategy.

decompstr; optional, default is ‘approx’

Decomposition approach.

pow_iterint; optional, default is 5

Number of power iterations to perform in randomized approximation.

n_oversampint; optional, default is 5

Oversampling parameter for randomized approximation.

diag_constfloat; optional, default is 1e-8

Constant added to diagonals of matrix prior to inversion.

random_stateint

Model random state. Ignored if exact eigenvalue decomposition approach used.

Attributes:
n_componentsint

Number of components. If None then reduce to minimum dimension of primary data.

mufloat or tuple or list

Augmenting objective strength(s).

pow_iterint

Number of power iterations to perform in randomized approximation.

n_oversampint

Oversampling parameter for randomized approximation.

diag_constfloat

Constant added to diagonals of matrix prior to inversion.

random_stateint

Model random state. Ignored if exact eigenvalue decomposition approach used.

mean_X_numpy.ndarray

1-dimensional (p,) mean array of primary data matrix.

mean_Y_numpy.ndarray

1-dimensional (q,) mean array of primary data matrix.

mean_Z_numpy.ndarray

1-dimensional (p + q,) mean array of combined primary and supervised data matrices.

B_numpy.ndarray

2-dimensional decomposition matrix.

W_numpy.ndarray

2-dimensional primary data loadings matrix.

D_numpy.ndarray

2-dimensional supervised data loadings matrix.

A_numpy.ndarray

2-dimensional encoding matrix. None if inference is set to ‘local’.

eigvals_numpy.ndarray

1-dimensional array of sorted decomposition matrix eigenvalues.

is_fitted_bool

Indicates whether model has been fitted.

Methods

fit(X, Y)

Fits AugmentedPCA model to data.

transform(X, Y)

Transforms data into scores using AugmentedPCA model formulation.

fit_transform(X, Y)

Fits AugumentedPCA model to data and transforms data into scores.

reconstruct(X, Y)

Reconstructs primary and supervised data.

get_components()

Returns primary data loadings / components. Alias for get_W().

get_W()

Returns primary data loadings.

get_D()

Returns supervised data loadings.

get_A()

Returns encoding matrix.

get_eigvals()

Returns 1-dimensional array of sorted decomposition matrix eigenvalues.

fit(X: ndarray, Y: ndarray | tuple | list)

Fits AugmentedPCA model to data.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices.

fit_transform(X: ndarray, Y: ndarray | tuple | list) ndarray

Fits AugumentedPCA model to data and transforms data into scores.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices.

Returns:
Snumpy.ndarray

2-dimensional (n x k) scores matrix.

get_A() ndarray

Returns encoding matrix.

Parameters:
none
Returns:
self.A_.copy()numpy.ndarray

2-dimensional (d x p) encoding matrix.

get_D() ndarray

Returns supervised data loadings.

Parameters:
none
Returns:
self.D_.copy()numpy.ndarray

Tuple of two 2-dimensional (qs x k), (qa x k) augmenting data loadings matrices.

get_W() ndarray

Returns primary data loadings.

Parameters:
none
Returns:
self.W_.copy()numpy.ndarray

2-dimensional (p x k) primary data loadings matrix.

get_components() ndarray

Returns primary data loadings / components.

Parameters:
none
Returns:
self.W_.copy()numpy.ndarray

2-dimensional (p x k) primary data loadings matrix.

get_eigvals() ndarray

Returns 1-dimensional array of sorted decomposition matrix eigenvalues.

Parameters:
none
Returns:
self.eigvals_.copy()numpy.ndarray

1-dimensional array of sorted eigenvalues.

reconstruct(X: ndarray, Y: ndarray | tuple | list) ndarray

Reconstruct primary and augmenting data.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices. Ignored if inference is set to ‘encoded’.

Returns:
X_reconnumpy.ndarray

2-dimensional (n x p) reconstruction of primary data.

Y_reconnumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) reconstruction of augmenting data or tuple of 2-dimensional (n x qs), (n x qa) augmenting data reconstructions.

transform(X: ndarray, Y: ndarray | tuple | list) ndarray

Transforms data into scores using AugmentedPCA model formulation.

Parameters:
Xnumpy.ndarray

2-dimensional (n x p) primary data matrix.

Ynumpy.ndarray or tuple / list of numpy.ndarrays

2-dimensional (n x q) augmenting data matrix or tuple of two 2-dimensional (n x qs), (n x qa) augmenting data matrices. Ignored if inference is set to ‘encoded’.

Returns:
Snumpy.ndarray

2-dimensional (n x k) scores matrix.