Package io.bhagat.ai.unsupervised
Class PrincipalComponentAnalysis
- java.lang.Object
-
- io.bhagat.ai.unsupervised.PrincipalComponentAnalysis
-
- All Implemented Interfaces:
java.io.Serializable
public class PrincipalComponentAnalysis extends java.lang.Object implements java.io.SerializableA class containing methods for Principal Component Analysis- Author:
- Bhagat
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private MatrixCintcurNumOfDimensionsthe current number of dimensionsMatrixdatadoubledefaultThresholdthe default threshold to decide whether a component has enough varianceprivate double[]eigenvaluesprivate Vector[]eigenvectorsprivate static longserialVersionUIDprivate MatrixX
-
Constructor Summary
Constructors Constructor Description PrincipalComponentAnalysis(Matrix X)Creates an object that will perform principal component analysis
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MatrixcenterData(Matrix X)Centers the data from the matrix X at the column meanstatic MatrixcovarianceMatrix(Matrix X)creates the covariance matrix for the datastatic MatrixcreateMatrix(byte[] data)creates a matrix from a byte arrayMatrixdimensionReduction()Reduces the dimensions of the data matrix so only the important dimensions remainMatrixdimensionReduction(double threshold)Reduces the dimensions of the data matrix so only the important dimensions remainMatrixdimensionReduction(int D)Reduces the dimensions of the data matrix into D dimensionsMatrixdimensionReduction(Matrix X)Reduces the dimensions of the data matrix so only the important dimensions remainMatrixdimensionReduction(Matrix X, double threshhold)Reduces the dimensions of the data matrix so only the important dimensions remainMatrixdimensionReduction(Matrix X, int D)Reduces the dimensions of the data matrix into D dimensionsMatrixdimensionReduction(Vector x)Reduces the dimensions of the data point into D dimensionsMatrixdimensionReduction(Vector x, double threshold)Reduces the dimensions of the data point into D dimensionsMatrixdimensionReduction(Vector x, int D)Reduces the dimensions of the data point into D dimensionsMatrixgetCenteredData()voidsetDataMatrix(Matrix X)sets the data of the object
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
defaultThreshold
public double defaultThreshold
the default threshold to decide whether a component has enough variance
-
curNumOfDimensions
public int curNumOfDimensions
the current number of dimensions
-
data
public Matrix data
-
X
private Matrix X
-
C
private Matrix C
-
eigenvalues
private double[] eigenvalues
-
eigenvectors
private Vector[] eigenvectors
-
-
Constructor Detail
-
PrincipalComponentAnalysis
public PrincipalComponentAnalysis(Matrix X)
Creates an object that will perform principal component analysis- Parameters:
X- the data matrix
-
-
Method Detail
-
setDataMatrix
public void setDataMatrix(Matrix X)
sets the data of the object- Parameters:
X- the data matrix
-
getCenteredData
public Matrix getCenteredData()
- Returns:
- gets the standardized data matrix X
-
createMatrix
public static Matrix createMatrix(byte[] data)
creates a matrix from a byte array- Parameters:
data- the byte data- Returns:
- the matrix
-
dimensionReduction
public Matrix dimensionReduction(Matrix X, int D)
Reduces the dimensions of the data matrix into D dimensions- Parameters:
X- the data to reduce the dimensions ofD- the number of ending dimensions- Returns:
- the transformed data
-
dimensionReduction
public Matrix dimensionReduction(Matrix X, double threshhold)
Reduces the dimensions of the data matrix so only the important dimensions remain- Parameters:
X- the data matrixthreshhold- the threshold for the eigenvalues defining what is important- Returns:
- the reduced data matrix
-
dimensionReduction
public Matrix dimensionReduction(Matrix X)
Reduces the dimensions of the data matrix so only the important dimensions remain- Parameters:
X- the data matrix- Returns:
- the reduced data matrix
-
dimensionReduction
public Matrix dimensionReduction(int D)
Reduces the dimensions of the data matrix into D dimensions- Parameters:
D- the number of ending dimensions- Returns:
- the transformed data
-
dimensionReduction
public Matrix dimensionReduction(double threshold)
Reduces the dimensions of the data matrix so only the important dimensions remain- Parameters:
threshold- the threshold for the eigenvalues defining what is important- Returns:
- the reduced data matrix
-
dimensionReduction
public Matrix dimensionReduction()
Reduces the dimensions of the data matrix so only the important dimensions remain- Returns:
- the reduced data matrix
-
dimensionReduction
public Matrix dimensionReduction(Vector x, int D)
Reduces the dimensions of the data point into D dimensions- Parameters:
x- a vector data pointD- the number of ending dimensions- Returns:
- the transformed data
-
dimensionReduction
public Matrix dimensionReduction(Vector x, double threshold)
Reduces the dimensions of the data point into D dimensions- Parameters:
x- a vector data pointthreshold- the threshold for the eigenvalues defining what is important- Returns:
- the transformed data
-
dimensionReduction
public Matrix dimensionReduction(Vector x)
Reduces the dimensions of the data point into D dimensions- Parameters:
x- a vector data point- Returns:
- the transformed data
-
centerData
public static Matrix centerData(Matrix X)
Centers the data from the matrix X at the column mean- Parameters:
X- the data- Returns:
- the centered data
-
-