Class: ExtraTreesClassifier
An extra-trees classifier.
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.
Constructors
new ExtraTreesClassifier()
new ExtraTreesClassifier(
opts
?):ExtraTreesClassifier
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.bootstrap ? | boolean | Whether bootstrap samples are used when building trees. If false , the whole dataset is used to build each tree. |
opts.ccp_alpha ? | any | Complexity 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.class_weight ? | any | Weights associated with classes in the form {class_label: weight} . If not given, all classes are supposed to have weight one. For multi-output problems, a list of dicts can be provided in the same order as the columns of y. Note that for multioutput (including multilabel) weights should be defined for each class of every column in its own dict. For example, for four-class multilabel classification weights should be [{0: 1, 1: 1}, {0: 1, 1: 5}, {0: 1, 1: 1}, {0: 1, 1: 1}] instead of [{1:1}, {2:5}, {3:1}, {4:1}]. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes \* np.bincount(y)) The “balanced_subsample” mode is the same as “balanced” except that weights are computed based on the bootstrap sample for every tree grown. For multi-output, the weights of each column of y will be multiplied. Note that these weights will be multiplied with sample_weight (passed through the fit method) if sample_weight is specified. |
opts.criterion ? | "gini" | "entropy" | "log_loss" | The function to measure the quality of a split. Supported criteria are “gini” for the Gini impurity and “log_loss” and “entropy” both for the Shannon information gain, see Mathematical formulation. Note: This parameter is tree-specific. |
opts.max_depth ? | number | The 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 ? | number | Grow 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 ? | number | If bootstrap is true , the number of samples to draw from X to train each base estimator. |
opts.min_impurity_decrease ? | number | A 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 ? | number | The 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 ? | number | The minimum number of samples required to split an internal node: |
opts.min_weight_fraction_leaf ? | number | The 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 ? | number | The number of trees in the forest. |
opts.n_jobs ? | number | The 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 ? | boolean | Whether to use out-of-bag samples to estimate the generalization score. By default, accuracy_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 ? | number | Controls 3 sources of randomness: |
opts.verbose ? | number | Controls the verbosity when fitting and predicting. |
opts.warm_start ? | boolean | When 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 ExtraTreesClassifier
Defined in generated/ensemble/ExtraTreesClassifier.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/ensemble/ExtraTreesClassifier.ts:23 |
_isInitialized | boolean | false | generated/ensemble/ExtraTreesClassifier.ts:22 |
_py | PythonBridge | undefined | generated/ensemble/ExtraTreesClassifier.ts:21 |
id | string | undefined | generated/ensemble/ExtraTreesClassifier.ts:18 |
opts | any | undefined | generated/ensemble/ExtraTreesClassifier.ts:19 |
Accessors
classes_
Get Signature
get classes_():
Promise
<ArrayLike
>
The classes labels (single output problem), or a list of arrays of class labels (multi-output problem).
Returns Promise
<ArrayLike
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:678
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/ExtraTreesClassifier.ts:624
estimators_
Get Signature
get estimators_():
Promise
<any
>
The collection of fitted sub-estimators.
Returns Promise
<any
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:651
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/ExtraTreesClassifier.ts:759
n_classes_
Get Signature
get n_classes_():
Promise
<number
|any
[]>
The number of classes (single output problem), or a list containing the number of classes for each output (multi-output problem).
Returns Promise
<number
| any
[]>
Defined in generated/ensemble/ExtraTreesClassifier.ts:705
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:732
n_outputs_
Get Signature
get n_outputs_():
Promise
<number
>
The number of outputs when fit
is performed.
Returns Promise
<number
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:786
oob_decision_function_
Get Signature
get oob_decision_function_():
Promise
<ArrayLike
[]>
Decision function computed with out-of-bag estimate on the training set. If n_estimators is small it might be possible that a data point was never left out during the bootstrap. In this case, oob_decision_function_
might contain NaN. This attribute exists only when oob_score
is true
.
Returns Promise
<ArrayLike
[]>
Defined in generated/ensemble/ExtraTreesClassifier.ts:840
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/ExtraTreesClassifier.ts:813
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/ensemble/ExtraTreesClassifier.ts:161
Methods
apply()
apply(
opts
):Promise
<ArrayLike
[]>
Apply trees in the forest to X, return leaf indices.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The 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/ExtraTreesClassifier.ts:234
decision_path()
decision_path(
opts
):Promise
<any
[]>
Return the decision path in the forest.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The 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/ExtraTreesClassifier.ts:268
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/ExtraTreesClassifier.ts:217
fit()
fit(
opts
):Promise
<any
>
Build a forest of trees from the training set (X, y).
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample 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 ? | ArrayLike | The 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 ? | ArrayLike | The target values (class labels in classification, real numbers in regression). |
Returns Promise
<any
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:304
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:350
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:174
predict()
predict(
opts
):Promise
<ArrayLike
>
Predict class for X.
The predicted class of an input sample is a vote by the trees in the forest, weighted by their probability estimates. That is, the predicted class is the one with highest mean probability estimate across the trees.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The 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/ExtraTreesClassifier.ts:388
predict_log_proba()
predict_log_proba(
opts
):Promise
<any
>
Predict class log-probabilities for X.
The predicted class log-probabilities of an input sample is computed as the log of the mean predicted class probabilities of the trees in the forest.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The 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/ExtraTreesClassifier.ts:424
predict_proba()
predict_proba(
opts
):Promise
<any
>
Predict class probabilities for X.
The predicted class probabilities of an input sample are computed as the mean predicted class probabilities of the trees in the forest. The class probability of a single tree is the fraction of samples of the same class in a leaf.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike | The 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/ExtraTreesClassifier.ts:462
score()
score(
opts
):Promise
<number
>
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike [] | Test samples. |
opts.y ? | ArrayLike | True labels for X . |
Returns Promise
<number
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:500
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in fit . |
Returns Promise
<any
>
Defined in generated/ensemble/ExtraTreesClassifier.ts:548
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in score . |
Returns Promise
<any
>