DocumentationClassesDecisionTreeRegressor

Class: DecisionTreeRegressor

A decision tree regressor.

Read more in the User Guide.

Python Reference

Constructors

new DecisionTreeRegressor()

new DecisionTreeRegressor(opts?): DecisionTreeRegressor

Parameters

ParameterTypeDescription
opts?object-
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 the half mean Poisson deviance to find splits.
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 a tree 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.monotonic_cst?any[]1: monotonic increase
opts.random_state?numberControls the randomness of the estimator. The features are always randomly permuted at each split, even if splitter is set to "best". When max_features < n_features, the algorithm will select max_features at random at each split before finding the best split among them. But the best found split may vary across different runs, even if max_features=n_features. That is the case, if the improvement of the criterion is identical for several splits and one split has to be selected at random. To obtain a deterministic behaviour during fitting, random_state has to be fixed to an integer. See Glossary for details.
opts.splitter?"random" | "best"The strategy used to choose the split at each node. Supported strategies are “best” to choose the best split and “random” to choose the best random split.

Returns DecisionTreeRegressor

Defined in generated/tree/DecisionTreeRegressor.ts:23

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/tree/DecisionTreeRegressor.ts:21
_isInitializedbooleanfalsegenerated/tree/DecisionTreeRegressor.ts:20
_pyPythonBridgeundefinedgenerated/tree/DecisionTreeRegressor.ts:19
idstringundefinedgenerated/tree/DecisionTreeRegressor.ts:16
optsanyundefinedgenerated/tree/DecisionTreeRegressor.ts:17

Accessors

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/tree/DecisionTreeRegressor.ts:728


max_features_

Get Signature

get max_features_(): Promise<number>

The inferred value of max_features.

Returns Promise<number>

Defined in generated/tree/DecisionTreeRegressor.ts:674


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/tree/DecisionTreeRegressor.ts:701


n_outputs_

Get Signature

get n_outputs_(): Promise<number>

The number of outputs when fit is performed.

Returns Promise<number>

Defined in generated/tree/DecisionTreeRegressor.ts:755


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/tree/DecisionTreeRegressor.ts:104


tree_

Get Signature

get tree_(): Promise<any>

The underlying Tree object. Please refer to help(sklearn.tree._tree.Tree) for attributes of Tree object and Understanding the decision tree structure for basic usage of these attributes.

Returns Promise<any>

Defined in generated/tree/DecisionTreeRegressor.ts:782

Methods

apply()

apply(opts): Promise<ArrayLike>

Return the index of the leaf that each sample is predicted as.

Parameters

ParameterTypeDescription
optsobject-
opts.check_input?booleanAllow to bypass several input checking. Don’t use this parameter unless you know what you’re doing.
opts.X?ArrayLikeThe input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.

Returns Promise<ArrayLike>

Defined in generated/tree/DecisionTreeRegressor.ts:177


cost_complexity_pruning_path()

cost_complexity_pruning_path(opts): Promise<any>

Compute the pruning path during Minimal Cost-Complexity Pruning.

See Minimal Cost-Complexity Pruning for details on the pruning process.

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. 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, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csc_matrix.
opts.y?ArrayLikeThe target values (class labels) as integers or strings.

Returns Promise<any>

Defined in generated/tree/DecisionTreeRegressor.ts:220


decision_path()

decision_path(opts): Promise<any[]>

Return the decision path in the tree.

Parameters

ParameterTypeDescription
optsobject-
opts.check_input?booleanAllow to bypass several input checking. Don’t use this parameter unless you know what you’re doing.
opts.X?ArrayLikeThe input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.

Returns Promise<any[]>

Defined in generated/tree/DecisionTreeRegressor.ts:266


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/tree/DecisionTreeRegressor.ts:160


fit()

fit(opts): Promise<any>

Build a decision tree regressor from the training set (X, y).

Parameters

ParameterTypeDescription
optsobject-
opts.check_input?booleanAllow to bypass several input checking. Don’t use this parameter unless you know what you’re doing.
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.
opts.X?ArrayLikeThe training input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csc_matrix.
opts.y?ArrayLikeThe target values (real numbers). Use dtype=np.float64 and order='C' for maximum efficiency.

Returns Promise<any>

Defined in generated/tree/DecisionTreeRegressor.ts:309


get_depth()

get_depth(opts): Promise<any>

Return the depth of the decision tree.

The depth of a tree is the maximum distance between the root and any leaf.

Parameters

ParameterType
optsobject

Returns Promise<any>

Defined in generated/tree/DecisionTreeRegressor.ts:362


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/tree/DecisionTreeRegressor.ts:394


get_n_leaves()

get_n_leaves(opts): Promise<any>

Return the number of leaves of the decision tree.

Parameters

ParameterType
optsobject

Returns Promise<any>

Defined in generated/tree/DecisionTreeRegressor.ts:430


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/tree/DecisionTreeRegressor.ts:117


predict()

predict(opts): Promise<ArrayLike>

Predict class or regression value for X.

For a classification model, the predicted class for each sample in X is returned. For a regression model, the predicted value based on X is returned.

Parameters

ParameterTypeDescription
optsobject-
opts.check_input?booleanAllow to bypass several input checking. Don’t use this parameter unless you know what you’re doing.
opts.X?ArrayLikeThe input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.

Returns Promise<ArrayLike>

Defined in generated/tree/DecisionTreeRegressor.ts:462


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/tree/DecisionTreeRegressor.ts:505


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.check_input?string | booleanMetadata routing for check_input parameter in fit.
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/tree/DecisionTreeRegressor.ts:553


set_predict_request()

set_predict_request(opts): Promise<any>

Request metadata passed to the predict 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.check_input?string | booleanMetadata routing for check_input parameter in predict.

Returns Promise<any>

Defined in generated/tree/DecisionTreeRegressor.ts:598


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/tree/DecisionTreeRegressor.ts:638