DocumentationClassesExtraTreesRegressor

Class: ExtraTreesRegressor

An extra-trees regressor.

This class implements a meta estimator that fits a number of randomized decision trees (a.k.a. extra-trees) on various sub-samples of the dataset and uses averaging to improve the predictive accuracy and control over-fitting.

Read more in the User Guide.

Python Reference

Constructors

new ExtraTreesRegressor()

new ExtraTreesRegressor(opts?): ExtraTreesRegressor

Parameters

ParameterTypeDescription
opts?object-
opts.bootstrap?booleanWhether bootstrap samples are used when building trees. If false, the whole dataset is used to build each tree.
opts.ccp_alpha?anyComplexity parameter used for Minimal Cost-Complexity Pruning. The subtree with the largest cost complexity that is smaller than ccp_alpha will be chosen. By default, no pruning is performed. See Minimal Cost-Complexity Pruning for details.
opts.criterion?"squared_error" | "absolute_error" | "friedman_mse" | "poisson"The function to measure the quality of a split. Supported criteria are “squared_error” for the mean squared error, which is equal to variance reduction as feature selection criterion and minimizes the L2 loss using the mean of each terminal node, “friedman_mse”, which uses mean squared error with Friedman’s improvement score for potential splits, “absolute_error” for the mean absolute error, which minimizes the L1 loss using the median of each terminal node, and “poisson” which uses reduction in Poisson deviance to find splits. Training using “absolute_error” is significantly slower than when using “squared_error”.
opts.max_depth?numberThe maximum depth of the 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_features?number | "sqrt" | "log2"The number of features to consider when looking for the best split:
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.max_samples?numberIf bootstrap is true, the number of samples to draw from X to train each base estimator.
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.monotonic_cst?any[]1: monotonically increasing
opts.n_estimators?numberThe number of trees in the forest.
opts.n_jobs?numberThe number of jobs to run in parallel. fit, predict, 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.oob_score?booleanWhether to use out-of-bag samples to estimate the generalization score. By default, r2_score is used. Provide a callable with signature metric(y_true, y_pred) to use a custom metric. Only available if bootstrap=True.
opts.random_state?numberControls 3 sources of randomness:
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 ExtraTreesRegressor

Defined in generated/ensemble/ExtraTreesRegressor.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/ensemble/ExtraTreesRegressor.ts:23
_isInitializedbooleanfalsegenerated/ensemble/ExtraTreesRegressor.ts:22
_pyPythonBridgeundefinedgenerated/ensemble/ExtraTreesRegressor.ts:21
idstringundefinedgenerated/ensemble/ExtraTreesRegressor.ts:18
optsanyundefinedgenerated/ensemble/ExtraTreesRegressor.ts:19

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/ExtraTreesRegressor.ts:533


estimators_

Get Signature

get estimators_(): Promise<any>

The collection of fitted sub-estimators.

Returns Promise<any>

Defined in generated/ensemble/ExtraTreesRegressor.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/ExtraTreesRegressor.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/ExtraTreesRegressor.ts:587


n_outputs_

Get Signature

get n_outputs_(): Promise<number>

The number of outputs.

Returns Promise<number>

Defined in generated/ensemble/ExtraTreesRegressor.ts:641


oob_prediction_

Get Signature

get oob_prediction_(): Promise<ArrayLike>

Prediction computed with out-of-bag estimate on the training set. This attribute exists only when oob_score is true.

Returns Promise<ArrayLike>

Defined in generated/ensemble/ExtraTreesRegressor.ts:695


oob_score_

Get Signature

get oob_score_(): Promise<number>

Score of the training dataset obtained using an out-of-bag estimate. This attribute exists only when oob_score is true.

Returns Promise<number>

Defined in generated/ensemble/ExtraTreesRegressor.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/ExtraTreesRegressor.ts:146

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/ExtraTreesRegressor.ts:219


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/ExtraTreesRegressor.ts:253


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/ExtraTreesRegressor.ts:202


fit()

fit(opts): Promise<any>

Build a forest of trees from the training set (X, y).

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 training 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 csc_matrix.
opts.y?ArrayLikeThe target values (class labels in classification, real numbers in regression).

Returns Promise<any>

Defined in generated/ensemble/ExtraTreesRegressor.ts:289


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/ExtraTreesRegressor.ts:335


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/ExtraTreesRegressor.ts:159


predict()

predict(opts): Promise<ArrayLike>

Predict regression target for X.

The predicted regression target of an input sample is computed as the mean predicted regression targets of the trees 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<ArrayLike>

Defined in generated/ensemble/ExtraTreesRegressor.ts:373


score()

score(opts): Promise<number>

Return the coefficient of determination of the prediction.

The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true \- y_pred)\*\* 2).sum() and \(v\) is the total sum of squares ((y_true \- y_true.mean()) \*\* 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeSample weights.
opts.X?ArrayLike[]Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
opts.y?ArrayLikeTrue values for X.

Returns Promise<number>

Defined in generated/ensemble/ExtraTreesRegressor.ts:409


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/ExtraTreesRegressor.ts:457


set_score_request()

set_score_request(opts): Promise<any>

Request metadata passed to the score 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 score.

Returns Promise<any>

Defined in generated/ensemble/ExtraTreesRegressor.ts:497