ExtraTreeClassifier
An extremely randomized tree classifier.
Extra-trees differ from classic decision trees in the way they are built. When looking for the best split to separate the samples of a node into two groups, random splits are drawn for each of the max\_features
randomly selected features and the best split among those is chosen. When max\_features
is set 1, this amounts to building a totally random decision tree.
Warning: Extra-trees should only be used within ensemble methods.
Read more in the User Guide.
Python Reference (opens in a new tab)
Constructors
constructor()
Signature
new ExtraTreeClassifier(opts?: object): ExtraTreeClassifier;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
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. Default Value 0 |
opts.class_weight? | any | Weights associated with classes in the form {class\_label: weight} . If undefined , 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)) 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. Default Value 'gini' |
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" | The number of features to consider when looking for the best split: Default Value 'sqrt' |
opts.max_leaf_nodes? | number | Grow 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? | 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: Default Value 0 |
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. Default Value 1 |
opts.min_samples_split? | number | The minimum number of samples required to split an internal node: Default Value 2 |
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. Default Value 0 |
opts.random_state? | number | Used to pick randomly the max\_features used at each split. 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. Default Value 'random' |
Returns
Defined in: generated/tree/ExtraTreeClassifier.ts:27 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/tree/ExtraTreeClassifier.ts:25 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/tree/ExtraTreeClassifier.ts:24 (opens in a new tab)
_py
PythonBridge
Defined in: generated/tree/ExtraTreeClassifier.ts:23 (opens in a new tab)
id
string
Defined in: generated/tree/ExtraTreeClassifier.ts:20 (opens in a new tab)
opts
any
Defined in: generated/tree/ExtraTreeClassifier.ts:21 (opens in a new tab)
Accessors
classes_
The classes labels (single output problem), or a list of arrays of class labels (multi-output problem).
Signature
classes_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/tree/ExtraTreeClassifier.ts:655 (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/tree/ExtraTreeClassifier.ts:763 (opens in a new tab)
max_features_
The inferred value of max_features.
Signature
max_features_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/tree/ExtraTreeClassifier.ts:682 (opens in a new tab)
n_classes_
The number of classes (for single output problems), or a list containing the number of classes for each output (for multi-output problems).
Signature
n_classes_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/tree/ExtraTreeClassifier.ts:709 (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/tree/ExtraTreeClassifier.ts:736 (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/tree/ExtraTreeClassifier.ts:790 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/tree/ExtraTreeClassifier.ts:118 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/tree/ExtraTreeClassifier.ts:122 (opens in a new tab)
tree_
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.
Signature
tree_(): Promise<any>;
Returns
Promise
<any
>
Defined in: generated/tree/ExtraTreeClassifier.ts:817 (opens in a new tab)
Methods
apply()
Return the index of the leaf that each sample is predicted as.
Signature
apply(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr\_matrix . |
opts.check_input? | boolean | Allow to bypass several input checking. Don’t use this parameter unless you know what you’re doing. Default Value true |
Returns
Promise
<ArrayLike
>
Defined in: generated/tree/ExtraTreeClassifier.ts:210 (opens in a new tab)
cost_complexity_pruning_path()
Compute the pruning path during Minimal Cost-Complexity Pruning.
See Minimal Cost-Complexity Pruning for details on the pruning process.
Signature
cost_complexity_pruning_path(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The 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.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. Splits are also ignored if they would result in any single class carrying a negative weight in either child node. |
opts.y? | ArrayLike | The target values (class labels) as integers or strings. |
Returns
Promise
<any
>
Defined in: generated/tree/ExtraTreeClassifier.ts:256 (opens in a new tab)
decision_path()
Return the decision path in the tree.
Signature
decision_path(opts: object): Promise<any[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr\_matrix . |
opts.check_input? | boolean | Allow to bypass several input checking. Don’t use this parameter unless you know what you’re doing. Default Value true |
Returns
Promise
<any
[]>
Defined in: generated/tree/ExtraTreeClassifier.ts:308 (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/tree/ExtraTreeClassifier.ts:193 (opens in a new tab)
fit()
Build a decision tree classifier from the training set (X, y).
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The 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.check_input? | boolean | Allow to bypass several input checking. Don’t use this parameter unless you know what you’re doing. Default Value true |
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. Splits are also ignored if they would result in any single class carrying a negative weight in either child node. |
opts.y? | ArrayLike | The target values (class labels) as integers or strings. |
Returns
Promise
<any
>
Defined in: generated/tree/ExtraTreeClassifier.ts:354 (opens in a new tab)
get_depth()
Return the depth of the decision tree.
The depth of a tree is the maximum distance between the root and any leaf.
Signature
get_depth(opts: object): Promise<any>;
Parameters
Name | Type |
---|---|
opts | object |
Returns
Promise
<any
>
Defined in: generated/tree/ExtraTreeClassifier.ts:414 (opens in a new tab)
get_n_leaves()
Return the number of leaves of the decision tree.
Signature
get_n_leaves(opts: object): Promise<any>;
Parameters
Name | Type |
---|---|
opts | object |
Returns
Promise
<any
>
Defined in: generated/tree/ExtraTreeClassifier.ts:442 (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
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/tree/ExtraTreeClassifier.ts:131 (opens in a new tab)
predict()
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.
Signature
predict(opts: object): Promise<ArrayLike>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr\_matrix . |
opts.check_input? | boolean | Allow to bypass several input checking. Don’t use this parameter unless you know what you’re doing. Default Value true |
Returns
Promise
<ArrayLike
>
Defined in: generated/tree/ExtraTreeClassifier.ts:474 (opens in a new tab)
predict_log_proba()
Predict class log-probabilities of the input samples X.
Signature
predict_log_proba(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The 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/ExtraTreeClassifier.ts:518 (opens in a new tab)
predict_proba()
Predict class probabilities of the input samples X.
The predicted class probability is the fraction of samples of the same class in a leaf.
Signature
predict_proba(opts: object): Promise<ArrayLike[]>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr\_matrix . |
opts.check_input? | boolean | Allow to bypass several input checking. Don’t use this parameter unless you know what you’re doing. Default Value true |
Returns
Promise
<ArrayLike
[]>
Defined in: generated/tree/ExtraTreeClassifier.ts:558 (opens in a new tab)
score()
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.
Signature
score(opts: object): Promise<number>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Test samples. |
opts.sample_weight? | ArrayLike | Sample weights. |
opts.y? | ArrayLike | True labels for X . |
Returns
Promise
<number
>
Defined in: generated/tree/ExtraTreeClassifier.ts:606 (opens in a new tab)