package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `BaseDecisionTree
]
type t = [ `BaseDecisionTree | `BaseEstimator | `MultiOutputMixin | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val as_estimator : t -> [ `BaseEstimator ] Obj.t
val as_multi_output : t -> [ `MultiOutputMixin ] Obj.t
val apply : ?check_input:bool -> x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

Return 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.t

Compute 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 : :class:`~sklearn.utils.Bunch` Dictionary-like object, with the following 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.t

Return 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 -> t

None

val get_depth : [> tag ] Obj.t -> Py.Object.t

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.

val get_n_leaves : [> tag ] Obj.t -> Py.Object.t

Return the number of leaves of the decision tree.

Returns ------- self.tree_.n_leaves : int Number of leaves.

val get_params : ?deep:bool -> [> tag ] Obj.t -> Dict.t

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.t

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 ---------- 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.

val set_params : ?params:(string * Py.Object.t) list -> [> tag ] Obj.t -> t

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.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Stdlib.Format.formatter -> t -> unit

Pretty-print the object to a formatter.