org.nd4j.linalg.dimensionalityreduction

## Class RandomProjection

• ```public class RandomProjection
extends Object```
Created by huitseeker on 7/28/17.
• ### Constructor Summary

Constructors
Constructor and Description
`RandomProjection(double eps)`
```RandomProjection(double eps, Random rng)```
`RandomProjection(int components)`
```RandomProjection(int components, Random rng)```
• ### Method Summary

All Methods
Modifier and Type Method and 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.1
`static List<Integer>` ```johnsonLindenStraussMinDim(int n, double... eps)```
`static List<Long>` ```johnsonLindenstraussMinDim(long[] 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 matrix
`INDArray` ```project(INDArray data, INDArray result)```
Create a copy random projection by using matrix product with a random matrix
`INDArray` `projecti(INDArray data)`
Create an in-place random projection by using in-place matrix product with a random matrix
`INDArray` ```projecti(INDArray data, INDArray result)```
Create an in-place random projection by using in-place matrix product with a random matrix
`protected static long[]` ```targetShape(INDArray X, double eps)```
Compute the target shape of a suitable projection matrix
`protected static long[]` ```targetShape(INDArray X, int targetDimension)```
Compute the target shape of a suitable projection matrix
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### 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

```protected 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: