package sklearn
Module Tree.BaseDecisionTreeSource
val apply :
?check_input:bool ->
x:[> `ArrayLike ] Np.Obj.t ->
[> tag ] Obj.t ->
[> `ArrayLike ] Np.Obj.tReturn the index of the leaf that each sample is predicted as.
.. versionadded:: 0.17
Parameters ---------- X : array-like, sparse matrix of shape (n_samples, n_features) The input samples. Internally, it will be converted to ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csr_matrix``.
check_input : bool, default=True Allow to bypass several input checking. Don't use this parameter unless you know what you do.
Returns ------- X_leaves : array-like of shape (n_samples,) For each datapoint x in X, return the index of the leaf x ends up in. Leaves are numbered within ``0; self.tree_.node_count)``, possibly with gaps in the numbering.
val cost_complexity_pruning_path :
?sample_weight:[> `ArrayLike ] Np.Obj.t ->
x:[> `ArrayLike ] Np.Obj.t ->
y:[> `ArrayLike ] Np.Obj.t ->
[> tag ] Obj.t ->
Py.Object.t * [> `ArrayLike ] Np.Obj.t * [> `ArrayLike ] Np.Obj.tCompute the pruning path during Minimal Cost-Complexity Pruning.
See :ref:`minimal_cost_complexity_pruning` for details on the pruning process.
Parameters ---------- X : array-like, sparse matrix of shape (n_samples, n_features) 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``.
y : array-like of shape (n_samples,) or (n_samples, n_outputs) The target values (class labels) as integers or strings.
sample_weight : array-like of shape (n_samples,), default=None Sample weights. If None, 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.
Returns ------- ccp_path : Bunch Dictionary-like object, with attributes:
ccp_alphas : ndarray Effective alphas of subtree during pruning.
impurities : ndarray Sum of the impurities of the subtree leaves for the corresponding alpha value in ``ccp_alphas``.
val decision_path :
?check_input:bool ->
x:[> `ArrayLike ] Np.Obj.t ->
[> tag ] Obj.t ->
[ `ArrayLike | `Object | `Spmatrix ] Np.Obj.tReturn the decision path in the tree.
.. versionadded:: 0.18
Parameters ---------- X : array-like, sparse matrix of shape (n_samples, n_features) The input samples. Internally, it will be converted to ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csr_matrix``.
check_input : bool, default=True Allow to bypass several input checking. Don't use this parameter unless you know what you do.
Returns ------- indicator : sparse matrix of shape (n_samples, n_nodes) Return a node indicator CSR matrix where non zero elements indicates that the samples goes through the nodes.
val fit :
?sample_weight:Py.Object.t ->
?check_input:Py.Object.t ->
?x_idx_sorted:Py.Object.t ->
x:Py.Object.t ->
y:Py.Object.t ->
[> tag ] Obj.t ->
tNone
Return the depth of the decision tree.
The depth of a tree is the maximum distance between the root and any leaf.
Returns ------- self.tree_.max_depth : int The maximum depth of the tree.
Return the number of leaves of the decision tree.
Returns ------- self.tree_.n_leaves : int Number of leaves.
Get parameters for this estimator.
Parameters ---------- deep : bool, default=True If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns ------- params : mapping of string to any Parameter names mapped to their values.
val predict :
?check_input:bool ->
x:[> `ArrayLike ] Np.Obj.t ->
[> tag ] Obj.t ->
[> `ArrayLike ] Np.Obj.tPredict 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 ---------- X : array-like, sparse matrix of shape (n_samples, n_features) The input samples. Internally, it will be converted to ``dtype=np.float32`` and if a sparse matrix is provided to a sparse ``csr_matrix``.
check_input : bool, default=True Allow to bypass several input checking. Don't use this parameter unless you know what you do.
Returns ------- y : array-like of shape (n_samples,) or (n_samples, n_outputs) The predicted classes, or the predict values.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form ``<component>__<parameter>`` so that it's possible to update each component of a nested object.
Parameters ---------- **params : dict Estimator parameters.
Returns ------- self : object Estimator instance.
Pretty-print the object to a formatter.