Package org.hipparchus.stat.projection
Class PCA
- java.lang.Object
-
- org.hipparchus.stat.projection.PCA
-
public class PCA extends Object
Principal component analysis (PCA) is a statistical technique for reducing the dimensionality of a dataset. PCA can be thought of as a projection or scaling of the data to reduce the number of dimensions but done in a way that preserves as much information as possible.- Since:
- 3.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PCA
fit(double[][] data)
Fit our model to the data, ready for subsequence transforms.double[][]
fitAndTransform(double[][] data)
Fit our model to the data and then transform it to the reduced dimensions.double[]
getCenter()
Get by column center (or mean) of the fitted data.double[][]
getComponents()
Returns the principal components of our projection model.int
getNumComponents()
GEt number of components.double[]
getVariance()
Get principal component variances.boolean
isBiasCorrection()
Check whether scaling (correlation), if in use, adjusts for bias.boolean
isScale()
Check whether scaling (correlation) or no scaling (covariance) is used.double[][]
transform(double[][] data)
Transform the supplied data using our projection model.
-
-
-
Constructor Detail
-
PCA
public PCA(int numC, boolean scale, boolean biasCorrection)
Create a PCA with the ability to adjust scaling parameters.- Parameters:
numC
- the number of componentsscale
- whether to also scale (correlation) rather than just center (covariance)biasCorrection
- whether to adjust for bias when scaling
-
PCA
public PCA(int numC)
A default PCA will center but not scale.- Parameters:
numC
- the number of components
-
-
Method Detail
-
getNumComponents
public int getNumComponents()
GEt number of components.- Returns:
- the number of components
-
isScale
public boolean isScale()
Check whether scaling (correlation) or no scaling (covariance) is used.- Returns:
- whether scaling (correlation) or no scaling (covariance) is used
-
isBiasCorrection
public boolean isBiasCorrection()
Check whether scaling (correlation), if in use, adjusts for bias.- Returns:
- whether scaling (correlation), if in use, adjusts for bias
-
getVariance
public double[] getVariance()
Get principal component variances.- Returns:
- the principal component variances, ordered from largest to smallest, which are the eigenvalues of the covariance or correlation matrix of the fitted data
-
getCenter
public double[] getCenter()
Get by column center (or mean) of the fitted data.- Returns:
- the by column center (or mean) of the fitted data
-
getComponents
public double[][] getComponents()
Returns the principal components of our projection model. These are the eigenvectors of our covariance/correlation matrix.- Returns:
- the principal components
-
fitAndTransform
public double[][] fitAndTransform(double[][] data)
Fit our model to the data and then transform it to the reduced dimensions.- Parameters:
data
- the input data- Returns:
- the fitted data
-
transform
public double[][] transform(double[][] data)
Transform the supplied data using our projection model.- Parameters:
data
- the input data- Returns:
- the fitted data
-
fit
public PCA fit(double[][] data)
Fit our model to the data, ready for subsequence transforms.- Parameters:
data
- the input data- Returns:
- this
-
-