Documentation
Classes
GaussianRandomProjection

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.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new GaussianRandomProjection(opts?: object): GaussianRandomProjection;

Parameters

NameTypeDescription
opts?object-
opts.compute_inverse_components?booleanLearn 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. Default Value false
opts.eps?numberParameter 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. Default Value 0.1
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. Default Value 'auto'
opts.random_state?numberControls 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 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/random_projection/GaussianRandomProjection.ts:121 (opens in a new tab)

fit()

Generate a sparse random projection matrix.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeTraining set: only the shape is used to find optimal random matrix dimensions based on the theory referenced in the afore mentioned papers.
opts.y?anyNot used, present here for API consistency by convention.

Returns

Promise<any>

Defined in: generated/random_projection/GaussianRandomProjection.ts:138 (opens in a new tab)

fit_transform()

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit\_params and returns a transformed version of X.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Input samples.
opts.fit_params?anyAdditional fit parameters.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns

Promise<any[]>

Defined in: generated/random_projection/GaussianRandomProjection.ts:180 (opens in a new tab)

get_feature_names_out()

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"\].

Signature

get_feature_names_out(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.input_features?anyOnly used to validate feature names with the names seen in fit.

Returns

Promise<any>

Defined in: generated/random_projection/GaussianRandomProjection.ts:234 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/random_projection/GaussianRandomProjection.ts:274 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/random_projection/GaussianRandomProjection.ts:75 (opens in a new tab)

inverse_transform()

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.

Signature

inverse_transform(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeData to be transformed back.

Returns

Promise<ArrayLike[]>

Defined in: generated/random_projection/GaussianRandomProjection.ts:316 (opens in a new tab)

set_output()

Set output container.

See Introducing the set_output API for an example on how to use the API.

Signature

set_output(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/random_projection/GaussianRandomProjection.ts:356 (opens in a new tab)

transform()

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

Signature

transform(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe input data to project into a smaller dimensional space.

Returns

Promise<ArrayLike[]>

Defined in: generated/random_projection/GaussianRandomProjection.ts:393 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/random_projection/GaussianRandomProjection.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/random_projection/GaussianRandomProjection.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/random_projection/GaussianRandomProjection.ts:21 (opens in a new tab)

id

string

Defined in: generated/random_projection/GaussianRandomProjection.ts:18 (opens in a new tab)

opts

any

Defined in: generated/random_projection/GaussianRandomProjection.ts:19 (opens in a new tab)

Accessors

components_

Random matrix used for the projection.

Signature

components_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/random_projection/GaussianRandomProjection.ts:457 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/random_projection/GaussianRandomProjection.ts:538 (opens in a new tab)

inverse_components_

Pseudo-inverse of the components, only computed if compute\_inverse\_components is true.

Signature

inverse_components_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/random_projection/GaussianRandomProjection.ts:484 (opens in a new tab)

n_components_

Concrete number of components computed when n_components=”auto”.

Signature

n_components_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/random_projection/GaussianRandomProjection.ts:430 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/random_projection/GaussianRandomProjection.ts:511 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/random_projection/GaussianRandomProjection.ts:62 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/random_projection/GaussianRandomProjection.ts:66 (opens in a new tab)