Class: GaussianRandomProjection
Reduce dimensionality through Gaussian random projection.
The components of the random matrix are drawn from N(0, 1 / n_components).
Read more in the User Guide.
Constructors
new GaussianRandomProjection()
new GaussianRandomProjection(
opts
?):GaussianRandomProjection
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.compute_inverse_components ? | boolean | Learn the inverse transform by computing the pseudo-inverse of the components during fit. Note that computing the pseudo-inverse does not scale well to large matrices. |
opts.eps ? | number | 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. Smaller values lead to better embedding and higher number of dimensions (n_components) in the target projection space. |
opts.n_components ? | number | "auto" | Dimensionality of the target projection space. 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. 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. |
opts.random_state ? | number | Controls the pseudo random number generator used to generate the projection matrix at fit time. Pass an int for reproducible output across multiple function calls. See Glossary. |
Returns GaussianRandomProjection
Defined in generated/random_projection/GaussianRandomProjection.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/random_projection/GaussianRandomProjection.ts:23 |
_isInitialized | boolean | false | generated/random_projection/GaussianRandomProjection.ts:22 |
_py | PythonBridge | undefined | generated/random_projection/GaussianRandomProjection.ts:21 |
id | string | undefined | generated/random_projection/GaussianRandomProjection.ts:18 |
opts | any | undefined | generated/random_projection/GaussianRandomProjection.ts:19 |
Accessors
components_
Get Signature
get components_():
Promise
<ArrayLike
[]>
Random matrix used for the projection.
Returns Promise
<ArrayLike
[]>
Defined in generated/random_projection/GaussianRandomProjection.ts:439
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/random_projection/GaussianRandomProjection.ts:520
inverse_components_
Get Signature
get inverse_components_():
Promise
<ArrayLike
[]>
Pseudo-inverse of the components, only computed if compute_inverse_components
is true
.
Returns Promise
<ArrayLike
[]>
Defined in generated/random_projection/GaussianRandomProjection.ts:466
n_components_
Get Signature
get n_components_():
Promise
<number
>
Concrete number of components computed when n_components=”auto”.
Returns Promise
<number
>
Defined in generated/random_projection/GaussianRandomProjection.ts:412
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/random_projection/GaussianRandomProjection.ts:493
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/random_projection/GaussianRandomProjection.ts:62
Methods
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/random_projection/GaussianRandomProjection.ts:118
fit()
fit(
opts
):Promise
<any
>
Generate a sparse random projection matrix.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | Training set: only the shape is used to find optimal random matrix dimensions based on the theory referenced in the afore mentioned papers. |
opts.y ? | any | Not used, present here for API consistency by convention. |
Returns Promise
<any
>
Defined in generated/random_projection/GaussianRandomProjection.ts:135
fit_transform()
fit_transform(
opts
):Promise
<any
[]>
Fit to data, then transform it.
Fits transformer to X
and y
with optional parameters fit_params
and returns a transformed version of X
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Additional fit parameters. |
opts.X ? | ArrayLike [] | Input samples. |
opts.y ? | ArrayLike | Target values (undefined for unsupervised transformations). |
Returns Promise
<any
[]>
Defined in generated/random_projection/GaussianRandomProjection.ts:176
get_feature_names_out()
get_feature_names_out(
opts
):Promise
<any
>
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.input_features ? | any | Only used to validate feature names with the names seen in fit . |
Returns Promise
<any
>
Defined in generated/random_projection/GaussianRandomProjection.ts:224
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/random_projection/GaussianRandomProjection.ts:262
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/random_projection/GaussianRandomProjection.ts:75
inverse_transform()
inverse_transform(
opts
):Promise
<ArrayLike
[]>
Project data back to its original space.
Returns an array X_original whose transform would be X. Note that even if X is sparse, X_original is dense: this may use a lot of RAM.
If compute_inverse_components
is false
, the inverse of the components is computed during each call to inverse_transform
which can be costly.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | Data to be transformed back. |
Returns Promise
<ArrayLike
[]>
Defined in generated/random_projection/GaussianRandomProjection.ts:302
set_output()
set_output(
opts
):Promise
<any
>
Set output container.
See Introducing the set_output API for an example on how to use the API.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.transform ? | "default" | "pandas" | "polars" | Configure output of transform and fit_transform . |
Returns Promise
<any
>
Defined in generated/random_projection/GaussianRandomProjection.ts:340
transform()
transform(
opts
):Promise
<ArrayLike
[]>
Project the data by using matrix product with the random matrix.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The input data to project into a smaller dimensional space. |
Returns Promise
<ArrayLike
[]>
Defined in generated/random_projection/GaussianRandomProjection.ts:376