Class PrincipalComponentAnalysis

  • All Implemented Interfaces:
    java.io.Serializable

    public class PrincipalComponentAnalysis
    extends java.lang.Object
    implements java.io.Serializable
    A class containing methods for Principal Component Analysis
    Author:
    Bhagat
    See Also:
    Serialized Form
    • Field Detail

      • defaultThreshold

        public double defaultThreshold
        the default threshold to decide whether a component has enough variance
      • curNumOfDimensions

        public int curNumOfDimensions
        the current number of dimensions
      • 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 of
        D - 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 matrix
        threshhold - 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 point
        D - 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 point
        threshold - 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
      • covarianceMatrix

        public static Matrix covarianceMatrix​(Matrix X)
        creates the covariance matrix for the data
        Parameters:
        X - the data matrix
        Returns:
        the covariance matrix