Class RandomProjection


  • public class RandomProjection
    extends Object
    • Constructor Detail

      • RandomProjection

        public RandomProjection​(double eps,
                                Random rng)
      • RandomProjection

        public RandomProjection​(double eps)
      • RandomProjection

        public RandomProjection​(int components,
                                Random rng)
      • RandomProjection

        public RandomProjection​(int components)
    • Method Detail

      • johnsonLindenstraussMinDim

        public static List<Integer> johnsonLindenstraussMinDim​(int[] n,
                                                               double... eps)
        Find a safe number of components to project this to, through the Johnson-Lindenstrauss lemma The minimum number n' of components to guarantee the eps-embedding is given by: n' >= 4 log(n) / (eps² / 2 - eps³ / 3) see http://cseweb.ucsd.edu/~dasgupta/papers/jl.pdf §2.1
        Parameters:
        n - Number of samples. If an array is given, it will compute a safe number of components array-wise.
        eps - Maximum distortion rate as defined by the Johnson-Lindenstrauss lemma. Will compute array-wise if an array is given.
        Returns:
      • johnsonLindenstraussMinDim

        public static List<Long> johnsonLindenstraussMinDim​(long[] n,
                                                            double... eps)
      • johnsonLindenStraussMinDim

        public static List<Integer> johnsonLindenStraussMinDim​(int n,
                                                               double... eps)
      • johnsonLindenStraussMinDim

        public static List<Long> johnsonLindenStraussMinDim​(long n,
                                                            double... eps)
      • targetShape

        public static long[] targetShape​(INDArray X,
                                         double eps)
        Compute the target shape of a suitable projection matrix
        Parameters:
        X - the Data tensor
        eps - the relative error used in the Johnson-Lindenstrauss estimation
        Returns:
        the shape of the projection matrix to use
      • targetShape

        protected static long[] targetShape​(INDArray X,
                                            int targetDimension)
        Compute the target shape of a suitable projection matrix
        Parameters:
        X - the Data Tensor
        targetDimension - a desired dimension
        Returns:
        the shape of the projection matrix to use
      • project

        public INDArray project​(INDArray data)
        Create a copy random projection by using matrix product with a random matrix
        Parameters:
        data -
        Returns:
        the projected matrix
      • project

        public INDArray project​(INDArray data,
                                INDArray result)
        Create a copy random projection by using matrix product with a random matrix
        Parameters:
        data -
        result - a placeholder result
        Returns:
      • projecti

        public INDArray projecti​(INDArray data)
        Create an in-place random projection by using in-place matrix product with a random matrix
        Parameters:
        data -
        Returns:
        the projected matrix
      • projecti

        public INDArray projecti​(INDArray data,
                                 INDArray result)
        Create an in-place random projection by using in-place matrix product with a random matrix
        Parameters:
        data -
        result - a placeholder result
        Returns: