apca.models¶
AugmentedPCA models class references and descriptions.
Supervised AugmentedPCA¶
-
class
apca.models.
SAPCA
(n_components=None, mu=1.0, inference='encoded', decomp='exact', 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’
Indicates model approximate inference strategy.
- decompstr; optional, default is ‘exact’
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.
fit_transform(X, Y)
Fits AugumentedPCA model to data and transforms data into scores.
get_A()
Returns encoding matrix.
get_D()
Returns supervised data loadings.
get_W()
Returns primary data loadings.
get_eigvals()
Returns 1-dimensional array of sorted decomposition matrix eigenvalues.
reconstruct(X, Y)
Reconstructs primary and supervised data.
transform(X, Y)
Transforms data into scores using AugmentedPCA model formulation.
-
fit
(X: numpy.ndarray, Y: numpy.ndarray)¶ Fits AugmentedPCA model to data.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) concomitant data matrix.
-
fit_transform
(X: numpy.ndarray, Y: numpy.ndarray) → numpy.ndarray¶ Fits AugumentedPCA model to data and transforms data into scores.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) concomitant data matrix.
- Returns
- Snumpy.ndarray
2-dimensional (n x k) scores matrix.
-
get_A
() → numpy.ndarray¶ Returns encoding matrix.
- Parameters
- none
- Returns
- self.A_.copy()numpy.ndarray
2-dimensional (d x p) encoding matrix.
-
get_D
() → numpy.ndarray¶ Returns supervised data loadings.
- Parameters
- none
- Returns
- self.D_.copy()numpy.ndarray
2-dimensional (q x k) supervised data loadings matrix.
-
get_W
() → numpy.ndarray¶ Returns primary data loadings.
- Parameters
- none
- Returns
- self.W_.copy()numpy.ndarray
2-dimensional (p x k) primary data loadings matrix.
-
get_eigvals
() → numpy.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: numpy.ndarray, Y: numpy.ndarray) → numpy.ndarray¶ Reconstruct primary and augmenting data.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) augmenting data matrix.
- Returns
- X_reconnumpy.ndarray
2-dimensional (n x p) reconstruction of primary data.
- Y_reconnumpy.ndarray
2-dimensional (n x q) reconstruction of augmenting data.
-
transform
(X: numpy.ndarray, Y: numpy.ndarray) → numpy.ndarray¶ Transforms data into scores using AugmentedPCA model formulation.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) concomitant data matrix.
- Returns
- Snumpy.ndarray
2-dimensional (n x k) scores matrix.
Adversarial AugmentedPCA¶
-
class
apca.models.
AAPCA
(n_components: Optional[int] = None, mu=1.0, inference='encoded', decomp='exact', 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’
Indicates model approximate inference strategy.
- decompstr; optional, default is ‘exact’
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.
fit_transform(X, Y)
Fits AugumentedPCA model to data and transforms data into scores.
get_A()
Returns encoding matrix.
get_D()
Returns concomitant data loadings.
get_W()
Returns primary data loadings.
get_eigvals()
Returns 1-dimensional array of sorted decomposition matrix eigenvalues.
reconstruct(X, Y)
Reconstructs primary and concomitant data.
transform(X, Y)
Transforms data into scores using AugmentedPCA model formulation.
-
fit
(X: numpy.ndarray, Y: numpy.ndarray)¶ Fits AugmentedPCA model to data.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) concomitant data matrix.
-
fit_transform
(X: numpy.ndarray, Y: numpy.ndarray) → numpy.ndarray¶ Fits AugumentedPCA model to data and transforms data into scores.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) concomitant data matrix.
- Returns
- Snumpy.ndarray
2-dimensional (n x k) scores matrix.
-
get_A
() → numpy.ndarray¶ Returns encoding matrix.
- Parameters
- none
- Returns
- self.A_.copy()numpy.ndarray
2-dimensional (d x p) encoding matrix.
-
get_D
() → numpy.ndarray¶ Returns concomitant data loadings.
- Parameters
- none
- Returns
- self.D_.copy()numpy.ndarray
2-dimensional (q x k) concomitant data loadings matrix.
-
get_W
() → numpy.ndarray¶ Returns primary data loadings.
- Parameters
- none
- Returns
- self.W_.copy()numpy.ndarray
2-dimensional (p x k) primary data loadings matrix.
-
get_eigvals
() → numpy.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: numpy.ndarray, Y: numpy.ndarray) → numpy.ndarray¶ Reconstruct primary and augmenting data.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) augmenting data matrix.
- Returns
- X_reconnumpy.ndarray
2-dimensional (n x p) reconstruction of primary data.
- Y_reconnumpy.ndarray
2-dimensional (n x q) reconstruction of augmenting data.
-
transform
(X: numpy.ndarray, Y: numpy.ndarray) → numpy.ndarray¶ Transforms data into scores using AugmentedPCA model formulation.
- Parameters
- Xnumpy.ndarray
2-dimensional (n x p) primary data matrix.
- Ynumpy.ndarray
2-dimensional (n x q) concomitant data matrix.
- Returns
- Snumpy.ndarray
2-dimensional (n x k) scores matrix.