jhplot.math.pca
Class PCA
- java.lang.Object
- 
- jhplot.math.pca.PCA
 
- 
 
 public final class PCA extends java.lang.ObjectThe class responsible mainly for preparing the PCA transformation parameters based on training data and executing the actual transformation on test data.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class and Description static classPCA.TransformationTypeType of the possible data transformation.
 - 
Constructor SummaryConstructors Constructor and Description PCA(Matrix data)Create the PCA transformation.PCA(Matrix data, boolean center)Create the PCA transformation.PCA(Matrix data, CovarianceMatrixEVDCalculator evdCalc)Create the PCA transformation.PCA(Matrix data, CovarianceMatrixEVDCalculator evdCalc, boolean center)Create the PCA transformation
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanbelongsToGeneratedSubspace(Matrix pt)Check if given point lies in PCA-generated subspace.static MatrixcalculateCovarianceMatrix(Matrix data)Function for JUnit testing purposes onlydoublegetEigenvalue(int dimNo)Get selected eigenvalueMatrixgetEigenvectorsMatrix()intgetInputDimsNo()Get number of dimensions of the input vectorsintgetOutputDimsNo()Get number of dimensions of the output vectorsMatrixtransform(Matrix data, PCA.TransformationType type)Execute selected transformation on given data.
 
- 
- 
- 
Constructor Detail- 
PCApublic PCA(Matrix data) Create the PCA transformation. Use the popular SVD method for internal calculations- Parameters:
- data- data matrix used to compute the PCA transformation. Rows of the matrix are the instances/samples, columns are dimensions. It is assumed that the matrix is already centered.
 
 - 
PCApublic PCA(Matrix data, boolean center) Create the PCA transformation. Use the popular SVD method for internal calculations- Parameters:
- data- data matrix used to compute the PCA transformation. Rows of the matrix are the instances/samples, columns are dimensions.
- center- should the data matrix be centered before doing the calculations?
 
 - 
PCApublic PCA(Matrix data, CovarianceMatrixEVDCalculator evdCalc) Create the PCA transformation.- Parameters:
- data- data matrix used to compute the PCA transformation. Rows of the matrix are the instances/samples, columns are dimensions. It is assumed that the matrix is already centered.
- evdCalc- method of computing eigenvalue decomposition of data's covariance matrix
 
 - 
PCApublic PCA(Matrix data, CovarianceMatrixEVDCalculator evdCalc, boolean center) Create the PCA transformation- Parameters:
- data- data matrix used to compute the PCA transformation. Rows of the matrix are the instances/samples, columns are dimensions.
- evdCalc- method of computing eigenvalue decomposition of data's covariance matrix
- center- should the data matrix be centered before doing the calculations?
 
 
- 
 - 
Method Detail- 
getEigenvectorsMatrixpublic Matrix getEigenvectorsMatrix() - Returns:
- matrix where eigenvectors are placed in columns
 
 - 
getEigenvaluepublic double getEigenvalue(int dimNo) Get selected eigenvalue- Parameters:
- dimNo- dimension number corresponding to given eigenvalue
 
 - 
getInputDimsNopublic int getInputDimsNo() Get number of dimensions of the input vectors
 - 
getOutputDimsNopublic int getOutputDimsNo() Get number of dimensions of the output vectors
 - 
transformpublic Matrix transform(Matrix data, PCA.TransformationType type) Execute selected transformation on given data.- Parameters:
- data- data to transform. Rows of the matrix are the instances/samples, columns are dimensions. If the original PCA data matrix was set to be centered, this matrix will also be centered using the same parameters.
- type- transformation to apply
- Returns:
- transformed data
 
 - 
belongsToGeneratedSubspacepublic boolean belongsToGeneratedSubspace(Matrix pt) Check if given point lies in PCA-generated subspace. If it does not, it means that the point doesn't belong to the transformation domain i.e. it is an outlier.- Parameters:
- pt- point. If the original PCA data matrix was set to be centered, this point will also be centered using the same parameters.
- Returns:
- true iff the point lies on all principal axes
 
 
- 
 
- 
DMelt 3.0 © DataMelt by jWork.ORG