Documentation
Classes
RandomTreesEmbedding

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 (opens in a new tab)

Constructors

constructor()

Signature

new RandomTreesEmbedding(opts?: object): RandomTreesEmbedding;

Parameters

NameTypeDescription
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. Default Value 5
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: Default Value 0
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. Default Value 1
opts.min_samples_split?numberThe minimum number of samples required to split an internal node: Default Value 2
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. Default Value 0
opts.n_estimators?numberNumber of trees in the forest. Default Value 100
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 (opens in a new tab) 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. Default Value true
opts.verbose?numberControls the verbosity when fitting and predicting. Default Value 0
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 weak-learners for details. Default Value false

Returns

RandomTreesEmbedding

Defined in: generated/ensemble/RandomTreesEmbedding.ts:27 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/ensemble/RandomTreesEmbedding.ts:25 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/ensemble/RandomTreesEmbedding.ts:24 (opens in a new tab)

_py

PythonBridge

Defined in: generated/ensemble/RandomTreesEmbedding.ts:23 (opens in a new tab)

id

string

Defined in: generated/ensemble/RandomTreesEmbedding.ts:20 (opens in a new tab)

opts

any

Defined in: generated/ensemble/RandomTreesEmbedding.ts:21 (opens in a new tab)

Accessors

estimator_

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

Signature

estimator_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/ensemble/RandomTreesEmbedding.ts:488 (opens in a new tab)

estimators_

The collection of fitted sub-estimators.

Signature

estimators_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/ensemble/RandomTreesEmbedding.ts:515 (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/ensemble/RandomTreesEmbedding.ts:569 (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/ensemble/RandomTreesEmbedding.ts:542 (opens in a new tab)

n_outputs_

The number of outputs when fit is performed.

Signature

n_outputs_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/ensemble/RandomTreesEmbedding.ts:596 (opens in a new tab)

one_hot_encoder_

One-hot encoder used to create the sparse embedding.

Signature

one_hot_encoder_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/ensemble/RandomTreesEmbedding.ts:623 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/ensemble/RandomTreesEmbedding.ts:112 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/ensemble/RandomTreesEmbedding.ts:116 (opens in a new tab)

Methods

apply()

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

Signature

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

Parameters

NameTypeDescription
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:202 (opens in a new tab)

decision_path()

Return the decision path in the forest.

Signature

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

Parameters

NameTypeDescription
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:237 (opens in a new tab)

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/ensemble/RandomTreesEmbedding.ts:185 (opens in a new tab)

fit()

Fit estimator.

Signature

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

Parameters

NameTypeDescription
optsobject-
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.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.y?anyNot used, present for API consistency by convention.

Returns

Promise<any>

Defined in: generated/ensemble/RandomTreesEmbedding.ts:274 (opens in a new tab)

fit_transform()

Fit estimator and transform dataset.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeInput data used to build forests. Use dtype=np.float32 for maximum efficiency.
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.y?anyNot used, present for API consistency by convention.

Returns

Promise<any[]>

Defined in: generated/ensemble/RandomTreesEmbedding.ts:323 (opens in a new tab)

get_feature_names_out()

Get output feature names for transformation.

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/ensemble/RandomTreesEmbedding.ts:374 (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/ensemble/RandomTreesEmbedding.ts:125 (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/ensemble/RandomTreesEmbedding.ts:414 (opens in a new tab)

transform()

Transform dataset.

Signature

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

Parameters

NameTypeDescription
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:451 (opens in a new tab)