DocumentationClassesRandomTreesEmbedding

Class: RandomTreesEmbedding

An ensemble of totally random trees.

An unsupervised transformation of a dataset to a high-dimensional sparse representation. A datapoint is coded according to which leaf of each tree it is sorted into. Using a one-hot encoding of the leaves, this leads to a binary coding with as many ones as there are trees in the forest.

The dimensionality of the resulting representation is n_out <= n_estimators \* max_leaf_nodes. If max_leaf_nodes \== None, the number of leaf nodes is at most n_estimators \* 2 \*\* max_depth.

Read more in the User Guide.

Python Reference

Constructors

new RandomTreesEmbedding()

new RandomTreesEmbedding(opts?): RandomTreesEmbedding

Parameters

ParameterTypeDescription
opts?object-
opts.max_depth?numberThe maximum depth of each tree. If undefined, then nodes are expanded until all leaves are pure or until all leaves contain less than min_samples_split samples.
opts.max_leaf_nodes?numberGrow trees with max_leaf_nodes in best-first fashion. Best nodes are defined as relative reduction in impurity. If undefined then unlimited number of leaf nodes.
opts.min_impurity_decrease?numberA node will be split if this split induces a decrease of the impurity greater than or equal to this value. The weighted impurity decrease equation is the following:
opts.min_samples_leaf?numberThe minimum number of samples required to be at a leaf node. A split point at any depth will only be considered if it leaves at least min_samples_leaf training samples in each of the left and right branches. This may have the effect of smoothing the model, especially in regression.
opts.min_samples_split?numberThe minimum number of samples required to split an internal node:
opts.min_weight_fraction_leaf?numberThe minimum weighted fraction of the sum total of weights (of all the input samples) required to be at a leaf node. Samples have equal weight when sample_weight is not provided.
opts.n_estimators?numberNumber of trees in the forest.
opts.n_jobs?numberThe number of jobs to run in parallel. fit, transform, decision_path and apply are all parallelized over the trees. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details.
opts.random_state?numberControls the generation of the random y used to fit the trees and the draw of the splits for each feature at the trees’ nodes. See Glossary for details.
opts.sparse_output?booleanWhether or not to return a sparse CSR matrix, as default behavior, or to return a dense array compatible with dense pipeline operators.
opts.verbose?numberControls the verbosity when fitting and predicting.
opts.warm_start?booleanWhen set to true, reuse the solution of the previous call to fit and add more estimators to the ensemble, otherwise, just fit a whole new forest. See Glossary and Fitting additional trees for details.

Returns RandomTreesEmbedding

Defined in generated/ensemble/RandomTreesEmbedding.ts:27

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/ensemble/RandomTreesEmbedding.ts:25
_isInitializedbooleanfalsegenerated/ensemble/RandomTreesEmbedding.ts:24
_pyPythonBridgeundefinedgenerated/ensemble/RandomTreesEmbedding.ts:23
idstringundefinedgenerated/ensemble/RandomTreesEmbedding.ts:20
optsanyundefinedgenerated/ensemble/RandomTreesEmbedding.ts:21

Accessors

estimator_

Get Signature

get estimator_(): Promise<any>

The child estimator template used to create the collection of fitted sub-estimators.

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:533


estimators_

Get Signature

get estimators_(): Promise<any>

The collection of fitted sub-estimators.

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:560


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/ensemble/RandomTreesEmbedding.ts:614


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/ensemble/RandomTreesEmbedding.ts:587


n_outputs_

Get Signature

get n_outputs_(): Promise<number>

The number of outputs when fit is performed.

Returns Promise<number>

Defined in generated/ensemble/RandomTreesEmbedding.ts:641


one_hot_encoder_

Get Signature

get one_hot_encoder_(): Promise<any>

One-hot encoder used to create the sparse embedding.

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:668


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/ensemble/RandomTreesEmbedding.ts:112

Methods

apply()

apply(opts): Promise<ArrayLike[]>

Apply trees in the forest to X, return leaf indices.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples. Internally, its dtype will be converted to dtype=np.float32. If a sparse matrix is provided, it will be converted into a sparse csr_matrix.

Returns Promise<ArrayLike[]>

Defined in generated/ensemble/RandomTreesEmbedding.ts:185


decision_path()

decision_path(opts): Promise<any[]>

Return the decision path in the forest.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe input samples. Internally, its dtype will be converted to dtype=np.float32. If a sparse matrix is provided, it will be converted into a sparse csr_matrix.

Returns Promise<any[]>

Defined in generated/ensemble/RandomTreesEmbedding.ts:219


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/ensemble/RandomTreesEmbedding.ts:168


fit()

fit(opts): Promise<any>

Fit estimator.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights. If undefined, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. In the case of classification, splits are also ignored if they would result in any single class carrying a negative weight in either child node.
opts.X?ArrayLikeThe input samples. Use dtype=np.float32 for maximum efficiency. Sparse matrices are also supported, use sparse csc_matrix for maximum efficiency.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:255


fit_transform()

fit_transform(opts): Promise<any[]>

Fit estimator and transform dataset.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights. If undefined, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. In the case of classification, splits are also ignored if they would result in any single class carrying a negative weight in either child node.
opts.X?ArrayLikeInput data used to build forests. Use dtype=np.float32 for maximum efficiency.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<any[]>

Defined in generated/ensemble/RandomTreesEmbedding.ts:299


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Get output feature names for transformation.

Parameters

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

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:345


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

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

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:383


init()

init(py): Promise<void>

Initializes the underlying Python resources.

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

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/ensemble/RandomTreesEmbedding.ts:125


set_fit_request()

set_fit_request(opts): Promise<any>

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:423


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

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/ensemble/RandomTreesEmbedding.ts:461


transform()

transform(opts): Promise<any[]>

Transform dataset.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeInput data to be transformed. Use dtype=np.float32 for maximum efficiency. Sparse matrices are also supported, use sparse csr_matrix for maximum efficiency.

Returns Promise<any[]>

Defined in generated/ensemble/RandomTreesEmbedding.ts:497