Class RandomProjection
- java.lang.Object
-
- org.nd4j.linalg.dimensionalityreduction.RandomProjection
-
public class RandomProjection extends Object
-
-
Constructor Summary
Constructors Constructor Description RandomProjection(double eps)
RandomProjection(double eps, Random rng)
RandomProjection(int components)
RandomProjection(int components, Random rng)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.1static List<Long>
johnsonLindenstraussMinDim(long[] n, double... eps)
static List<Integer>
johnsonLindenStraussMinDim(int n, double... eps)
static List<Long>
johnsonLindenStraussMinDim(long n, double... eps)
INDArray
project(INDArray data)
Create a copy random projection by using matrix product with a random matrixINDArray
project(INDArray data, INDArray result)
Create a copy random projection by using matrix product with a random matrixINDArray
projecti(INDArray data)
Create an in-place random projection by using in-place matrix product with a random matrixINDArray
projecti(INDArray data, INDArray result)
Create an in-place random projection by using in-place matrix product with a random matrixstatic long[]
targetShape(INDArray X, double eps)
Compute the target shape of a suitable projection matrixprotected static long[]
targetShape(INDArray X, int targetDimension)
Compute the target shape of a suitable projection matrix
-
-
-
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 tensoreps
- 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 TensortargetDimension
- 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
-
-