# GaussianRandomProjection

### *class* cuml.random_projection.GaussianRandomProjection(n_components='auto', , eps=0.1, random_state=None, output_type=None, verbose=False)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/random_projection/random_projection.py#L168)

Reduce dimensionality through Gaussian random projection.

The components of the random matrix are drawn from N(0, 1 / n_components).

* **Parameters:**
  **n_components**
  : Dimensionality of the target projection space.
    <br/>
    n_components can be automatically adjusted according to the
    number of samples in the dataset and the bound given by the
    Johnson-Lindenstrauss lemma. In that case the quality of the
    embedding is controlled by the `eps` parameter.
    <br/>
    It should be noted that Johnson-Lindenstrauss lemma can yield
    very conservative estimated of the required number of components
    as it makes no assumption on the structure of the dataset.

  **eps**
  : Parameter to control the quality of the embedding according to
    the Johnson-Lindenstrauss lemma when `n_components` is set to
    ‘auto’. The value should be strictly positive.
    <br/>
    Smaller values lead to better embedding and higher number of
    dimensions (n_components) in the target projection space.

  **random_state**
  : Controls the pseudo random number generator used to generate the
    projection matrix at fit time.

  **output_type**
  : Return results and set estimator attributes to the indicated output
    type. If None, the output type set at the module level
    (`cuml.global_settings.output_type`) will be used. See
    [Output Data Type Configuration](../../cuml/index.html.md#output-data-type-configuration) for more info.

  **verbose**
  : Sets logging level. It must be one of `cuml.common.logger.level_*`.
    See [Verbosity Levels](../../cuml/index.html.md#verbosity-levels) for more info.
* **Attributes:**
  **n_components_**
  : Concrete number of components computed when n_components=”auto”.

  **components_**
  : Random matrix used for the projection.

  **n_features_in_**
  : Number of features seen during fit.

### Notes

Inspired by Scikit-learn’s implementation:
[https://scikit-learn.org/stable/modules/random_projection.html](https://scikit-learn.org/stable/modules/random_projection.html)

Currently passing a sparse array to [`transform`](#cuml.random_projection.GaussianRandomProjection.transform) may result in close (but
not exactly identical) results due to [https://github.com/cupy/cupy/issues/9323](https://github.com/cupy/cupy/issues/9323).

### Examples

```pycon
>>> from cuml.random_projection import GaussianRandomProjection
>>> from cuml.datasets import make_blobs
>>> X, _ = make_blobs(n_samples=200, n_features=1000, random_state=42)
>>> model = GaussianRandomProjection(n_components=50, random_state=42)
>>> X_new = model.fit_transform(X)
>>> X_new.shape
(200, 50)
```

<!-- !! processed by numpydoc !! -->

#### fit(X, y=None)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/random_projection/random_projection.py#L89)

Generate a random projection matrix.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **y**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

<!-- !! processed by numpydoc !! -->

#### fit_transform(X, y=None)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/random_projection/random_projection.py#L161)

Fit to data, then transform it.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **y**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

<!-- !! processed by numpydoc !! -->

#### get_feature_names_out(input_features=None)

Get output feature names for transformation.

The feature names out will prefixed by the lowercased class name. For
example, if the transformer outputs 3 features, then the feature names
out are: `["class_name0", "class_name1", "class_name2"]`.

* **Parameters:**
  **input_features**
  : Only used to validate feature names with the names seen in [`fit`](#cuml.random_projection.GaussianRandomProjection.fit).
* **Returns:**
  **feature_names_out**
  : Transformed feature names.

<!-- !! processed by numpydoc !! -->

#### get_params(deep=True)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/base.py#L191)

Returns a dict of all params owned by this class. If the child class
has appropriately overridden the `_get_param_names` method and does not
need anything other than what is there in this method, then it doesn’t
have to override this method

<!-- !! processed by numpydoc !! -->

#### set_params(\*\*params)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/base.py#L200)

Accepts a dict of params and updates the corresponding ones owned by
this class. If the child class has appropriately overridden the
`_get_param_names` method and does not need anything other than what is,
there in this method, then it doesn’t have to override this method

<!-- !! processed by numpydoc !! -->

#### transform(X)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/random_projection/random_projection.py#L132)

Project the data by taking the matrix product with the random matrix.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

<!-- !! processed by numpydoc !! -->
