
    -iP/                       S r SSKrSSKrSSKJrJr  SSKJr  SSKJrJ	r	  SSK
rSSKJr  SSKJr  SS	KJrJrJrJrJrJrJr  SS
KJrJrJr  SSKJrJrJrJ r   SSK!J"r"  SSK#J$r$J%r%J&r&J'r'J(r(J)r)  SSK*J+r+J,r,J-r-  SSK+J.r.  SSK,J/r/  SSK-J0r0J1r1J2r2J3r3J4r4  SSK5J6r6  / SQr7\-Rp                  r8\-Rr                  r9\+Rt                  \+Rv                  \+Rv                  S.r<\+Rz                  \+R|                  \+R~                  \+R                  S.rA\,R                  \,R                  S.rD\,R                  \,R                  S.rG " S S\\\S9rH " S S\\H5      rI " S S\\H5      rJ " S S \I5      rK " S! S"\J5      rLg)#z
This module gathers tree-based methods, including decision, regression and
randomized trees. Single and multi-output problems are both handled.
    N)ABCMetaabstractmethod)ceil)IntegralReal)issparse)metadata_routing   )BaseEstimatorClassifierMixinMultiOutputMixinRegressorMixin_fit_contextcloneis_classifier)Bunchcheck_random_statecompute_sample_weight)HiddenInterval
RealNotInt
StrOptions)check_classification_targets)_assert_all_finite_element_wise_check_n_features_check_sample_weightassert_all_finitecheck_is_fittedvalidate_data   )
_criterion	_splitter_tree)	Criterion)Splitter)BestFirstTreeBuilderDepthFirstTreeBuilderTree_build_pruned_tree_ccpccp_pruning_path)_any_isnan_axis0)DecisionTreeClassifierDecisionTreeRegressorExtraTreeClassifierExtraTreeRegressor)ginilog_lossentropy)squared_errorfriedman_mseabsolute_errorpoissonbestrandomc                     ^  \ rS rSr% SrS\R                  0r\" SS15      /\	" \
SSSS	9S/\	" \
S
SSS	9\	" \SSSS	9/\	" \
SSSS	9\	" \SSSS	9/\	" \SSSS	9/\	" \
SSSS	9\	" \SSSS	9\" SS15      S/S/\	" \
S
SSS	9S/\	" \SSSS	9/\	" \SSSS	9/SS/S.r\\S'   \SSSS.S j5       rS rS rS rS'S jr   S(S jrS rS)S jrS)S  jrS)S! jrS" rS'S# jr\S$ 5       rU 4S% jrS&r U =r!$ )*BaseDecisionTree[   znBase class for decision trees.

Warning: This class should not be used directly.
Use derived classes instead.
check_inputr8   r9   r    Nleft)closedr
                 ?rightneitherg      ?bothsqrtlog2random_statez
array-like)splitter	max_depthmin_samples_splitmin_samples_leafmin_weight_fraction_leafmax_featuresrG   max_leaf_nodesmin_impurity_decrease	ccp_alphamonotonic_cst_parameter_constraints)class_weightrP   rQ   c                    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        Xl
        Xl        Xl        g N)	criterionrH   rI   rJ   rK   rL   rM   rN   rG   rO   rS   rP   rQ   )selfrV   rH   rI   rJ   rK   rL   rM   rN   rG   rO   rS   rP   rQ   s                 H/var/www/html/venv/lib/python3.13/site-packages/sklearn/tree/_classes.py__init__BaseDecisionTree.__init__   sN    $ # "!2 0(@%(,(%:"("*    c                 D    [        U 5        U R                  R                  $ )zReturn 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.
)r   tree_rI   rW   s    rX   	get_depthBaseDecisionTree.get_depth   s     	zz###r[   c                 D    [        U 5        U R                  R                  $ )zsReturn the number of leaves of the decision tree.

Returns
-------
self.tree_.n_leaves : int
    Number of leaves.
)r   r]   n_leavesr^   s    rX   get_n_leavesBaseDecisionTree.get_n_leaves   s     	zz"""r[   c                     [        U5      (       + =(       a9    U R                  5       R                  R                  =(       a    U R                  S L $ rU   )r   __sklearn_tags__
input_tags	allow_nanrQ   )rW   Xs     rX   _support_missing_values(BaseDecisionTree._support_missing_values   s@    O +%%'22<<+""d*	
r[   c                    U=(       d    U R                   R                  n[        USS9nU R                  U5      (       d  [	        U40 UD6  g[
        R                  " SS9   [
        R                  " U5      nSSS5        [
        R                  " W5      (       d  [        U4[
        SS.UD6  [
        R                  " U5      (       d  g[        U5      nU$ ! , (       d  f       Ne= f)a  Return boolean mask denoting if there are missing values for each feature.

This method also ensures that X is finite.

Parameter
---------
X : array-like of shape (n_samples, n_features), dtype=DOUBLE
    Input data.

estimator_name : str or None, default=None
    Name to use when raising an error. Defaults to the class name.

Returns
-------
missing_values_in_feature_mask : ndarray of shape (n_features,), or None
    Missing value mask. If missing values are not supported or there
    are no missing values, return None.
ri   )estimator_name
input_nameNignore)overT)xprh   )	__class____name__dictrj   r   nperrstatesumisfiniter   isnanr+   )rW   ri   rm   common_kwargsoverall_summissing_values_in_feature_masks         rX   '_compute_missing_values_in_feature_mask8BaseDecisionTree._compute_missing_values_in_feature_mask   s    & (B4>>+B+BNsK++A..a1=1[[h'&&)K ( {{;''+AV"VV xx$$)9!)<&-- ('s   !C
C%c           	      L   [        U R                  5      nU(       Ga  [        [        SSS9n[        SS S9n[	        XX'U4S9u  pU R                  U5      n[        U5      (       ak  UR                  5         UR                  R                  [        R                  :w  d(  UR                  R                  [        R                  :w  a  [        S5      eU R                  S:X  aN  [        R                  " US:  5      (       a  [        S	5      e[        R                   " U5      S::  a  [        S
5      eUR"                  u  ol        ['        U 5      n
[        R(                  " U5      nS nUR*                  S:X  a  [        R,                  " US5      nUR"                  S   U l        U
(       GaP  [1        U5        [        R2                  " U5      n/ U l        / U l        U R8                  b  [        R2                  " U5      n[        R:                  " UR"                  [<        S9n[?        U R.                  5       Hk  n[        R@                  " US S 2U4   SS9u  oS S 2U4'   U R4                  RC                  U5        U R6                  RC                  UR"                  S   5        Mm     UnU R8                  b  [E        U R8                  W5      n[        RF                  " U R6                  [        RH                  S9U l        [K        USS 5      [L        :w  d  URN                  RP                  (       d  [        RR                  " U[L        S9nU RT                  c.  [        RV                  " [        RX                  5      RZ                  OU RT                  n[]        U R^                  [`        Rb                  5      (       a  U R^                  nO[e        U R^                  U	-  5      n[]        U Rf                  [`        Rb                  5      (       a  U Rf                  nO$[e        U Rf                  U	-  5      n[[        SU5      n[[        USU-  5      n[]        U Rh                  [j        5      (       a  U Rh                  S:X  a4  [[        S[=        [        Rl                  " U R$                  5      5      5      nOU Rh                  S:X  a3  [[        S[=        [        Rn                  " U R$                  5      5      5      nOU Rh                  c  U R$                  nOu[]        U Rh                  [`        Rb                  5      (       a  U Rh                  nO?U Rh                  S:  a-  [[        S[=        U Rh                  U R$                  -  5      5      nOSnWU l8        U Rr                  c  SOU Rr                  n[u        U5      U	:w  a  [        S[u        U5      U	4-  5      eUb  [w        X1[L        S9nUb
  Ub  X;-  nOUnUc  U Rx                  U	-  nO#U Rx                  [        R                   " U5      -  nU R                  n[]        U[z        5      (       d[  U
(       a/  [|        U R                     " U R.                  U R6                  5      nO;[~        U R                     " U R.                  U	5      nO[2        R                  " U5      n[        U5      (       a  [        O[        nU R                  nU R                  c  S nGO<U R.                  S:  a  [        S5      e[        R                  " U R                  5      nUR"                  S   UR"                  S   :w  a5  [        SR                  UR"                  S   UR"                  S   5      5      e[        R                  " US5      n[        R                  " U5      (       d$  [        R@                  " U5      n[        SU 35      e[        R                  " U[        R                  S9n['        U 5      (       a#  U R6                  S   S:  a  [        S5      eUS-  n[]        U R                  [        5      (       d$  UU R                     " UU Rp                  UUUU5      n['        U 5      (       a1  [        U R$                  U R6                  U R.                  5      U lL        OU[        U R$                  [        RF                  " S/U R.                  -  [        RH                  S9U R.                  5      U lL        US:  a  [        UUUUUU R                  5      nO[        UUUUUUU R                  5      nUR                  U R                  XX55        U R.                  S:X  a8  ['        U 5      (       a(  U R6                  S   U l        U R4                  S   U l        U R                  5         U $ )NcscF)dtypeaccept_sparseensure_all_finite)	ensure_2dr   )validate_separately3No support for np.int64 index based sparse matricesr6   r   zLSome value(s) of y are negative which is not allowed for Poisson regression.zCSum of y is not positive which is necessary for Poisson regression.r    )r    r   T)return_inverser   r
   rE   rF   r@   r   z7Number of labels=%d does not match number of samples=%dzAMonotonicity constraints are not supported with multiple outputs.z@monotonic_cst has shape {} but the input data X has {} features.)r   r   r    zCmonotonic_cst must be None or an array-like of -1, 0 or 1, but got zIMonotonicity constraints are not supported with multiclass classification)Rr   rG   rt   DTYPEr   r}   r   sort_indicesindicesr   ru   intcindptr
ValueErrorrV   anyrw   shapen_features_in_r   
atleast_1dndimreshape
n_outputs_r   copyclasses_
n_classes_rS   zerosintrangeuniqueappendr   arrayintpgetattrDOUBLEflags
contiguousascontiguousarrayrI   iinfoint32max
isinstancerK   numbersr   r   rJ   rM   strrE   rF   max_features_rN   lenr   rL   r$   CRITERIA_CLFCRITERIA_REGdeepcopySPARSE_SPLITTERSDENSE_SPLITTERSrH   rQ   asarrayformatisinallint8r%   r(   r]   r'   rO   r&   build_prune_tree)rW   ri   ysample_weightr=   r|   rG   check_X_paramscheck_y_params	n_samplesis_classificationexpanded_class_weight
y_original	y_encodedk	classes_krI   rK   rJ   rM   rN   min_weight_leafrV   	SPLITTERSrH   rQ   valid_constraintsunique_constaints_valuebuilders                                rX   _fitBaseDecisionTree._fit   s    *$*;*;< "5EN "E>N 0PDA
 <<Q? + {{ 99??bgg-2771J$M  ~~*66!a%==$?  66!9>$<  *+&	&)$/MM! $66Q; 

1g&A''!*(+
ADM DO  ,WWQZ
4I4??+-/YYqAwt-T*	QT?$$Y/&&yq'9: , A  ,(=%%z)% !hhtbggFDO1gt$.agg6H6H$$Qf5A.2nn.DBHHRXX&**$..	d++W-=-=>>#44#D$9$9I$EFd,,g.>.>?? $ 6 6 $T%;%;i%G H #A'8 9 117G3GHd''--  F*"1c"''$2E2E*F&GH""f,"1c"''$2E2E*F&GH&..L))7+;+;<<,,L  3&"1c$*;*;d>Q>Q*Q&RS )#22:@S@Sq6YIq69%& 
 $0PM ,( - E 5  ";;iGO";;bff]>SSO NN	)Y// (8OOT__	 )8)T	 i0I(0$	==% M" W  JJt'9'9:M""1%3 ))/0C0CA0FPQ
)S  !#z B66+,,*,))M*B' 346  JJ}BGGDMT""??1%)$)  #$--22 /"" H d114??DOOTDJ##!t.bgg>	DJ A+! **G +! **G 	djj!V??aM$$7$7"ooa0DO MM!,DMr[   c           	      \   U(       a  U R                  U5      (       a  SnOSn[        U U[        SSUS9n[        U5      (       a[  UR                  R
                  [        R                  :w  d(  UR                  R
                  [        R                  :w  a  [        S5      eU$ [        XSS9  U$ )z6Validate the training data on predict (probabilities).z	allow-nanTcsrF)r   r   resetr   r   )r   )rj   r   r   r   r   r   ru   r   r   r   r   )rW   ri   r=   r   s       rX   _validate_X_predict$BaseDecisionTree._validate_X_predict  s    ++A..$/!$(!#"3A {{		277*ahhnn.G !VWW  dU3r[   c                    [        U 5        U R                  X5      nU R                  R                  U5      nUR                  S   n[        U 5      (       a  U R                  S:X  a-  U R                  R                  [        R                  " USS9SS9$ U R                  S   R                  n[        R                  " X@R                  4US9n[        U R                  5       HA  nU R                  U   R                  [        R                  " USS2U4   SS9SS9USS2U4'   MC     U$ U R                  S:X  a	  USS2S4   $ USS2SS2S4   $ )a  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're doing.

Returns
-------
y : array-like of shape (n_samples,) or (n_samples, n_outputs)
    The predicted classes, or the predict values.
r   r    )axisr   N)r   r   r]   predictr   r   r   r   takeru   argmaxr   r   r   )rW   ri   r=   probar   
class_typepredictionsr   s           rX   r   BaseDecisionTree.predict  s0   . 	$$Q4

""1%GGAJ	 !#}}))"))E*B)KK "]]1-33
 hh	??'C:Vt/A(,a(8(=(=		%1+A6Q )> )K1% 0
 #" !#QT{" Q1W~%r[   c                 p    [        U 5        U R                  X5      nU R                  R                  U5      $ )a  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're doing.

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.
)r   r   r]   applyrW   ri   r=   s      rX   r   BaseDecisionTree.apply-  s1    0 	$$Q4zz""r[   c                 Z    U R                  X5      nU R                  R                  U5      $ )az  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're doing.

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.
)r   r]   decision_pathr   s      rX   r   BaseDecisionTree.decision_pathI  s)    , $$Q4zz''**r[   c                    [        U 5        U R                  S:X  a  g[        U 5      (       aA  [        R                  " U R
                  5      n[        U R                  XR                  5      nOP[        U R                  [        R                  " S/U R                  -  [        R                  S9U R                  5      n[        X R                  U R                  5        X l        g)z1Prune tree using Minimal Cost-Complexity Pruning.r@   Nr    r   )r   rP   r   ru   r   r   r(   r   r   r   r   r)   r]   )rW   	n_classespruned_trees      rX   r   BaseDecisionTree._prune_treeb  s    >>S  doo6It22IOK##!t.bgg>	K 	{JJG 
r[   c                     [        U 5      R                  SS9nUR                  XUS9  [        S0 [	        UR
                  5      D6$ )a  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``.
r@   )rP   )r    )r   
set_paramsfitr   r*   r]   )rW   ri   r   r   ests        rX   cost_complexity_pruning_path-BaseDecisionTree.cost_complexity_pruning_pathx  sD    F Dk$$s$3M23'		233r[   c                 L    [        U 5        U R                  R                  5       $ )a  Return the feature importances.

The importance of a feature is computed as the (normalized) total
reduction of the criterion brought by that feature.
It is also known as the Gini importance.

Warning: impurity-based feature importances can be misleading for
high cardinality features (many unique values). See
:func:`sklearn.inspection.permutation_importance` as an alternative.

Returns
-------
feature_importances_ : ndarray of shape (n_features,)
    Normalized total reduction of criteria by feature
    (Gini importance).
)r   r]   compute_feature_importancesr^   s    rX   feature_importances_%BaseDecisionTree.feature_importances_  s    $ 	zz5577r[   c                 F   > [         TU ]  5       nSUR                  l        U$ NT)superrf   rg   sparse)rW   tagsrr   s     rX   rf   !BaseDecisionTree.__sklearn_tags__  s!    w')!%r[   )rP   rS   r   rV   rI   rM   r   rN   rO   rK   rJ   rL   rQ   r   r   r   rG   rH   r]   rU   )NTNT)"rs   
__module____qualname____firstlineno____doc__r	   UNUSED,_BaseDecisionTree__metadata_request__predictr   r   r   r   r   rR   rt   __annotations__r   rY   r_   rc   rj   r}   r   r   r   r   r   r   r   propertyr   rf   __static_attributes____classcell__rr   s   @rX   r;   r;   [   s    $12B2I2I"J   234xD@$GXq$v6Zc':

 Xq$v6Zc)<
 &.dCV%L$MXq$v6Zc':'(	
 ((#HafEtL"*4d6"J!KtS$v>?&--$D 2  + +>$	#
&.X '+yv01&f#8+2!,%4N 8 8* r[   r;   )	metaclassc                   *  ^  \ rS rSr% SrS\R                  0rS\R                  0r0 \	R                  E\" 1 Sk5      \" \5      /\\\" S15      S/S.Er
\\S'   S	S
SSSSSSSSSSSS.U 4S jjr\" SS9SU 4S jj5       rSS jrS rU 4S jrSrU =r$ )r,   i  as&  A decision tree classifier.

Read more in the :ref:`User Guide <tree>`.

Parameters
----------
criterion : {"gini", "entropy", "log_loss"}, default="gini"
    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 :ref:`tree_mathematical_formulation`.

splitter : {"best", "random"}, default="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.

max_depth : int, default=None
    The maximum depth of the tree. If None, then nodes are expanded until
    all leaves are pure or until all leaves contain less than
    min_samples_split samples.

min_samples_split : int or float, default=2
    The minimum number of samples required to split an internal node:

    - If int, then consider `min_samples_split` as the minimum number.
    - If float, then `min_samples_split` is a fraction and
      `ceil(min_samples_split * n_samples)` are the minimum
      number of samples for each split.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_samples_leaf : int or float, default=1
    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.

    - If int, then consider `min_samples_leaf` as the minimum number.
    - If float, then `min_samples_leaf` is a fraction and
      `ceil(min_samples_leaf * n_samples)` are the minimum
      number of samples for each node.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_weight_fraction_leaf : float, default=0.0
    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.

max_features : int, float or {"sqrt", "log2"}, default=None
    The number of features to consider when looking for the best split:

    - If int, then consider `max_features` features at each split.
    - If float, then `max_features` is a fraction and
      `max(1, int(max_features * n_features_in_))` features are considered at
      each split.
    - If "sqrt", then `max_features=sqrt(n_features)`.
    - If "log2", then `max_features=log2(n_features)`.
    - If None, then `max_features=n_features`.

    .. note::

        The search for a split does not stop until at least one
        valid partition of the node samples is found, even if it requires to
        effectively inspect more than ``max_features`` features.

random_state : int, RandomState instance or None, default=None
    Controls 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 :term:`Glossary <random_state>` for details.

max_leaf_nodes : int, default=None
    Grow a tree with ``max_leaf_nodes`` in best-first fashion.
    Best nodes are defined as relative reduction in impurity.
    If None then unlimited number of leaf nodes.

min_impurity_decrease : float, default=0.0
    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::

        N_t / N * (impurity - N_t_R / N_t * right_impurity
                            - N_t_L / N_t * left_impurity)

    where ``N`` is the total number of samples, ``N_t`` is the number of
    samples at the current node, ``N_t_L`` is the number of samples in the
    left child, and ``N_t_R`` is the number of samples in the right child.

    ``N``, ``N_t``, ``N_t_R`` and ``N_t_L`` all refer to the weighted sum,
    if ``sample_weight`` is passed.

    .. versionadded:: 0.19

class_weight : dict, list of dict or "balanced", default=None
    Weights associated with classes in the form ``{class_label: weight}``.
    If None, 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.

ccp_alpha : non-negative float, default=0.0
    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
    :ref:`minimal_cost_complexity_pruning` for details. See
    :ref:`sphx_glr_auto_examples_tree_plot_cost_complexity_pruning.py`
    for an example of such pruning.

    .. versionadded:: 0.22

monotonic_cst : array-like of int of shape (n_features), default=None
    Indicates the monotonicity constraint to enforce on each feature.
      - 1: monotonic increase
      - 0: no constraint
      - -1: monotonic decrease

    If monotonic_cst is None, no constraints are applied.

    Monotonicity constraints are not supported for:
      - multiclass classifications (i.e. when `n_classes > 2`),
      - multioutput classifications (i.e. when `n_outputs_ > 1`),
      - classifications trained on data with missing values.

    The constraints hold over the probability of the positive class.

    Read more in the :ref:`User Guide <monotonic_cst_gbdt>`.

    .. versionadded:: 1.4

Attributes
----------
classes_ : ndarray of shape (n_classes,) or list of ndarray
    The classes labels (single output problem),
    or a list of arrays of class labels (multi-output problem).

feature_importances_ : ndarray of shape (n_features,)
    The impurity-based feature importances.
    The higher, the more important the feature.
    The importance of a feature is computed as the (normalized)
    total reduction of the criterion brought by that feature.  It is also
    known as the Gini importance [4]_.

    Warning: impurity-based feature importances can be misleading for
    high cardinality features (many unique values). See
    :func:`sklearn.inspection.permutation_importance` as an alternative.

max_features_ : int
    The inferred value of max_features.

n_classes_ : int or list of int
    The number of classes (for single output problems),
    or a list containing the number of classes for each
    output (for multi-output problems).

n_features_in_ : int
    Number of features seen during :term:`fit`.

    .. versionadded:: 0.24

feature_names_in_ : ndarray of shape (`n_features_in_`,)
    Names of features seen during :term:`fit`. Defined only when `X`
    has feature names that are all strings.

    .. versionadded:: 1.0

n_outputs_ : int
    The number of outputs when ``fit`` is performed.

tree_ : Tree instance
    The underlying Tree object. Please refer to
    ``help(sklearn.tree._tree.Tree)`` for attributes of Tree object and
    :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py`
    for basic usage of these attributes.

See Also
--------
DecisionTreeRegressor : A decision tree regressor.

Notes
-----
The default values for the parameters controlling the size of the trees
(e.g. ``max_depth``, ``min_samples_leaf``, etc.) lead to fully grown and
unpruned trees which can potentially be very large on some data sets. To
reduce memory consumption, the complexity and size of the trees should be
controlled by setting those parameter values.

The :meth:`predict` method operates using the :func:`numpy.argmax`
function on the outputs of :meth:`predict_proba`. This means that in
case the highest predicted probabilities are tied, the classifier will
predict the tied class with the lowest index in :term:`classes_`.

References
----------

.. [1] https://en.wikipedia.org/wiki/Decision_tree_learning

.. [2] L. Breiman, J. Friedman, R. Olshen, and C. Stone, "Classification
       and Regression Trees", Wadsworth, Belmont, CA, 1984.

.. [3] T. Hastie, R. Tibshirani and J. Friedman. "Elements of Statistical
       Learning", Springer, 2009.

.. [4] L. Breiman, and A. Cutler, "Random Forests",
       https://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm

Examples
--------
>>> from sklearn.datasets import load_iris
>>> from sklearn.model_selection import cross_val_score
>>> from sklearn.tree import DecisionTreeClassifier
>>> clf = DecisionTreeClassifier(random_state=0)
>>> iris = load_iris()
>>> cross_val_score(clf, iris.data, iris.target, cv=10)
...                             # doctest: +SKIP
...
array([ 1.     ,  0.93,  0.86,  0.93,  0.93,
        0.93,  0.93,  1.     ,  0.93,  1.      ])
r=   >   r0   r2   r1   balancedN)rV   rS   rR   r0   r8   r
   r    r@   rV   rH   rI   rJ   rK   rL   rM   rG   rN   rO   rS   rP   rQ   c                8   > [         TU ]  UUUUUUUU	UUU
UUS9  g )N)rV   rH   rI   rJ   rK   rL   rM   rN   rS   rG   rO   rQ   rP   r   rY   rW   rV   rH   rI   rJ   rK   rL   rM   rG   rN   rO   rS   rP   rQ   rr   s                 rX   rY   DecisionTreeClassifier.__init__  s>    " 	/-%=%)%%"7' 	 	
r[   Tprefer_skip_nested_validationc                 (   > [         TU ]  UUUUS9  U $ )a  Build a decision tree classifier from the training set (X, y).

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.

check_input : bool, default=True
    Allow to bypass several input checking.
    Don't use this parameter unless you know what you're doing.

Returns
-------
self : DecisionTreeClassifier
    Fitted estimator.
r   r=   r   r   rW   ri   r   r   r=   rr   s        rX   r   DecisionTreeClassifier.fit  s)    > 	'#	 	 	
 r[   c                 N   [        U 5        U R                  X5      nU R                  R                  U5      nU R                  S:X  a  USS2SU R
                  24   $ / n[        U R                  5       H-  nUSS2USU R
                  U   24   nUR                  U5        M/     U$ )a  Predict class probabilities of the input samples X.

The predicted class probability is the fraction of samples of the same
class in a leaf.

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're doing.

Returns
-------
proba : ndarray of shape (n_samples, n_classes) or list of n_outputs             such arrays if n_outputs > 1
    The class probabilities of the input samples. The order of the
    classes corresponds to that in the attribute :term:`classes_`.
r    N)r   r   r]   r   r   r   r   r   )rW   ri   r=   r   	all_probar   proba_ks          rX   predict_proba$DecisionTreeClassifier.predict_proba  s    0 	$$Q4

""1%??a-doo--..I4??+1&:(:&: :;  ) , r[   c                     U R                  U5      nU R                  S:X  a  [        R                  " U5      $ [	        U R                  5       H  n[        R                  " X#   5      X#'   M     U$ )a0  Predict class log-probabilities of the input samples X.

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

Returns
-------
proba : ndarray of shape (n_samples, n_classes) or list of n_outputs             such arrays if n_outputs > 1
    The class log-probabilities of the input samples. The order of the
    classes corresponds to that in the attribute :term:`classes_`.
r    )r  r   ru   logr   )rW   ri   r   r   s       rX   predict_log_proba(DecisionTreeClassifier.predict_log_proba-  s\    " ""1%??a66%=  4??+66%(+ , Lr[   c                    > [         TU ]  5       nU R                  S;   =(       a    U R                  S;   nSUR                  l        X!R                  l        U$ )Nr7   >   r0   r2   r1   Tr   rf   rH   rV   classifier_tagsmulti_labelrg   rh   rW   r   rh   rr   s      rX   rf   'DecisionTreeClassifier.__sklearn_tags__I  sV    w') MM%77 
DNN O
 =
	
 ,0($-!r[   r   r   r   )rs   r   r   r   r   r	   r   8_DecisionTreeClassifier__metadata_request__predict_proba._DecisionTreeClassifier__metadata_request__fitr;   rR   r   r   r$   rt   listr   rY   r   r   r  r  rf   r   r   r  s   @rX   r,   r,     s    rl *78H8O8O(P%,.>.E.EF$

1
1$ !@A6)CTUtZ%=tD$D  !$!
 
B 5$ 6$L#J8 r[   r,   c                      ^  \ rS rSr% SrS\R                  0r0 \R                  ES\
" 1 Sk5      \" \5      /0Er	\\S'   SSS	S
SSS	S	S	SSS	S.U 4S jjr\" SS9SU 4S jj5       rS rU 4S jrSrU =r$ )r-   iW  a!  A decision tree regressor.

Read more in the :ref:`User Guide <tree>`.

Parameters
----------
criterion : {"squared_error", "friedman_mse", "absolute_error",             "poisson"}, default="squared_error"
    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.

    .. versionadded:: 0.18
       Mean Absolute Error (MAE) criterion.

    .. versionadded:: 0.24
        Poisson deviance criterion.

splitter : {"best", "random"}, default="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.

max_depth : int, default=None
    The maximum depth of the tree. If None, then nodes are expanded until
    all leaves are pure or until all leaves contain less than
    min_samples_split samples.

    For an example of how ``max_depth`` influences the model, see
    :ref:`sphx_glr_auto_examples_tree_plot_tree_regression.py`.

min_samples_split : int or float, default=2
    The minimum number of samples required to split an internal node:

    - If int, then consider `min_samples_split` as the minimum number.
    - If float, then `min_samples_split` is a fraction and
      `ceil(min_samples_split * n_samples)` are the minimum
      number of samples for each split.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_samples_leaf : int or float, default=1
    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.

    - If int, then consider `min_samples_leaf` as the minimum number.
    - If float, then `min_samples_leaf` is a fraction and
      `ceil(min_samples_leaf * n_samples)` are the minimum
      number of samples for each node.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_weight_fraction_leaf : float, default=0.0
    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.

max_features : int, float or {"sqrt", "log2"}, default=None
    The number of features to consider when looking for the best split:

    - If int, then consider `max_features` features at each split.
    - If float, then `max_features` is a fraction and
      `max(1, int(max_features * n_features_in_))` features are considered at each
      split.
    - If "sqrt", then `max_features=sqrt(n_features)`.
    - If "log2", then `max_features=log2(n_features)`.
    - If None, then `max_features=n_features`.

    Note: the search for a split does not stop until at least one
    valid partition of the node samples is found, even if it requires to
    effectively inspect more than ``max_features`` features.

random_state : int, RandomState instance or None, default=None
    Controls 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 :term:`Glossary <random_state>` for details.

max_leaf_nodes : int, default=None
    Grow a tree with ``max_leaf_nodes`` in best-first fashion.
    Best nodes are defined as relative reduction in impurity.
    If None then unlimited number of leaf nodes.

min_impurity_decrease : float, default=0.0
    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::

        N_t / N * (impurity - N_t_R / N_t * right_impurity
                            - N_t_L / N_t * left_impurity)

    where ``N`` is the total number of samples, ``N_t`` is the number of
    samples at the current node, ``N_t_L`` is the number of samples in the
    left child, and ``N_t_R`` is the number of samples in the right child.

    ``N``, ``N_t``, ``N_t_R`` and ``N_t_L`` all refer to the weighted sum,
    if ``sample_weight`` is passed.

    .. versionadded:: 0.19

ccp_alpha : non-negative float, default=0.0
    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
    :ref:`minimal_cost_complexity_pruning` for details. See
    :ref:`sphx_glr_auto_examples_tree_plot_cost_complexity_pruning.py`
    for an example of such pruning.

    .. versionadded:: 0.22

monotonic_cst : array-like of int of shape (n_features), default=None
    Indicates the monotonicity constraint to enforce on each feature.
      - 1: monotonic increase
      - 0: no constraint
      - -1: monotonic decrease

    If monotonic_cst is None, no constraints are applied.

    Monotonicity constraints are not supported for:
      - multioutput regressions (i.e. when `n_outputs_ > 1`),
      - regressions trained on data with missing values.

    Read more in the :ref:`User Guide <monotonic_cst_gbdt>`.

    .. versionadded:: 1.4

Attributes
----------
feature_importances_ : ndarray of shape (n_features,)
    The feature importances.
    The higher, the more important the feature.
    The importance of a feature is computed as the
    (normalized) total reduction of the criterion brought
    by that feature. It is also known as the Gini importance [4]_.

    Warning: impurity-based feature importances can be misleading for
    high cardinality features (many unique values). See
    :func:`sklearn.inspection.permutation_importance` as an alternative.

max_features_ : int
    The inferred value of max_features.

n_features_in_ : int
    Number of features seen during :term:`fit`.

    .. versionadded:: 0.24

feature_names_in_ : ndarray of shape (`n_features_in_`,)
    Names of features seen during :term:`fit`. Defined only when `X`
    has feature names that are all strings.

    .. versionadded:: 1.0

n_outputs_ : int
    The number of outputs when ``fit`` is performed.

tree_ : Tree instance
    The underlying Tree object. Please refer to
    ``help(sklearn.tree._tree.Tree)`` for attributes of Tree object and
    :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py`
    for basic usage of these attributes.

See Also
--------
DecisionTreeClassifier : A decision tree classifier.

Notes
-----
The default values for the parameters controlling the size of the trees
(e.g. ``max_depth``, ``min_samples_leaf``, etc.) lead to fully grown and
unpruned trees which can potentially be very large on some data sets. To
reduce memory consumption, the complexity and size of the trees should be
controlled by setting those parameter values.

References
----------

.. [1] https://en.wikipedia.org/wiki/Decision_tree_learning

.. [2] L. Breiman, J. Friedman, R. Olshen, and C. Stone, "Classification
       and Regression Trees", Wadsworth, Belmont, CA, 1984.

.. [3] T. Hastie, R. Tibshirani and J. Friedman. "Elements of Statistical
       Learning", Springer, 2009.

.. [4] L. Breiman, and A. Cutler, "Random Forests",
       https://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm

Examples
--------
>>> from sklearn.datasets import load_diabetes
>>> from sklearn.model_selection import cross_val_score
>>> from sklearn.tree import DecisionTreeRegressor
>>> X, y = load_diabetes(return_X_y=True)
>>> regressor = DecisionTreeRegressor(random_state=0)
>>> cross_val_score(regressor, X, y, cv=10)
...                    # doctest: +SKIP
...
array([-0.39, -0.46,  0.02,  0.06, -0.50,
       0.16,  0.11, -0.73, -0.30, -0.00])
r=   rV   >   r6   r4   r3   r5   rR   r3   r8   Nr
   r    r@   )rV   rH   rI   rJ   rK   rL   rM   rG   rN   rO   rP   rQ   c                6   > [         TU ]  UUUUUUUU	UU
UUS9  g )N)rV   rH   rI   rJ   rK   rL   rM   rN   rG   rO   rP   rQ   r  )rW   rV   rH   rI   rJ   rK   rL   rM   rG   rN   rO   rP   rQ   rr   s                rX   rY   DecisionTreeRegressor.__init__?  s;      	/-%=%)%"7' 	 	
r[   Tr
  c                 (   > [         TU ]  UUUUS9  U $ )a  Build a decision tree regressor from the training set (X, y).

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 (real numbers). Use ``dtype=np.float64`` and
    ``order='C'`` for maximum efficiency.

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.

check_input : bool, default=True
    Allow to bypass several input checking.
    Don't use this parameter unless you know what you're doing.

Returns
-------
self : DecisionTreeRegressor
    Fitted estimator.
r  r  r  s        rX   r   DecisionTreeRegressor.fit^  s)    < 	'#	 	 	
 r[   c                    [         R                  " U[        SS9n[         R                  " UR                  S   [         R
                  SS9n[         R                  " U[         R                  SS9nU R                  R                  XU5        U$ )a  Fast partial dependence computation.

Parameters
----------
grid : ndarray of shape (n_samples, n_target_features), dtype=np.float32
    The grid points on which the partial dependence should be
    evaluated.
target_features : ndarray of shape (n_target_features), dtype=np.intp
    The set of target features for which the partial dependence
    should be evaluated.

Returns
-------
averaged_predictions : ndarray of shape (n_samples,), dtype=np.float64
    The value of the partial dependence function on each grid point.
C)r   orderr   )r   r   r*  )	ru   r   r   r   r   float64r   r]   compute_partial_dependence)rW   gridtarget_featuresaveraged_predictionss       rX   %_compute_partial_dependence_recursion;DecisionTreeRegressor._compute_partial_dependence_recursion  sp    " zz$e37!xx**Q-rzz 
 **_BGG3O

--#7	
 $#r[   c                    > [         TU ]  5       nU R                  S;   =(       a    U R                  S;   nX!R                  l        U$ )Nr7   >   r6   r4   r3   r   rf   rH   rV   rg   rh   r  s      rX   rf   &DecisionTreeRegressor.__sklearn_tags__  sH    w') MM%77 
DNN O
 =
	
 %.!r[   r   r   )rs   r   r   r   r   r	   r   -_DecisionTreeRegressor__metadata_request__fitr;   rR   r   r   r$   rt   r   rY   r   r   r0  rf   r   r   r  s   @rX   r-   r-   W  s    Yz  -.>.E.EF$

1
1$UV9
$D  "!$!
 
> 5# 6#J$8
 
r[   r-   c                   X   ^  \ rS rSrSrSSSSSSS	SSSSSSS
.U 4S jjrU 4S jrSrU =r$ )r.   i  a%  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 :ref:`User Guide <tree>`.

Parameters
----------
criterion : {"gini", "entropy", "log_loss"}, default="gini"
    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 :ref:`tree_mathematical_formulation`.

splitter : {"random", "best"}, default="random"
    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.

max_depth : int, default=None
    The maximum depth of the tree. If None, then nodes are expanded until
    all leaves are pure or until all leaves contain less than
    min_samples_split samples.

min_samples_split : int or float, default=2
    The minimum number of samples required to split an internal node:

    - If int, then consider `min_samples_split` as the minimum number.
    - If float, then `min_samples_split` is a fraction and
      `ceil(min_samples_split * n_samples)` are the minimum
      number of samples for each split.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_samples_leaf : int or float, default=1
    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.

    - If int, then consider `min_samples_leaf` as the minimum number.
    - If float, then `min_samples_leaf` is a fraction and
      `ceil(min_samples_leaf * n_samples)` are the minimum
      number of samples for each node.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_weight_fraction_leaf : float, default=0.0
    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.

max_features : int, float, {"sqrt", "log2"} or None, default="sqrt"
    The number of features to consider when looking for the best split:

    - If int, then consider `max_features` features at each split.
    - If float, then `max_features` is a fraction and
      `max(1, int(max_features * n_features_in_))` features are considered at
      each split.
    - If "sqrt", then `max_features=sqrt(n_features)`.
    - If "log2", then `max_features=log2(n_features)`.
    - If None, then `max_features=n_features`.

    .. versionchanged:: 1.1
        The default of `max_features` changed from `"auto"` to `"sqrt"`.

    Note: the search for a split does not stop until at least one
    valid partition of the node samples is found, even if it requires to
    effectively inspect more than ``max_features`` features.

random_state : int, RandomState instance or None, default=None
    Used to pick randomly the `max_features` used at each split.
    See :term:`Glossary <random_state>` for details.

max_leaf_nodes : int, default=None
    Grow a tree with ``max_leaf_nodes`` in best-first fashion.
    Best nodes are defined as relative reduction in impurity.
    If None then unlimited number of leaf nodes.

min_impurity_decrease : float, default=0.0
    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::

        N_t / N * (impurity - N_t_R / N_t * right_impurity
                            - N_t_L / N_t * left_impurity)

    where ``N`` is the total number of samples, ``N_t`` is the number of
    samples at the current node, ``N_t_L`` is the number of samples in the
    left child, and ``N_t_R`` is the number of samples in the right child.

    ``N``, ``N_t``, ``N_t_R`` and ``N_t_L`` all refer to the weighted sum,
    if ``sample_weight`` is passed.

    .. versionadded:: 0.19

class_weight : dict, list of dict or "balanced", default=None
    Weights associated with classes in the form ``{class_label: weight}``.
    If None, 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.

ccp_alpha : non-negative float, default=0.0
    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
    :ref:`minimal_cost_complexity_pruning` for details. See
    :ref:`sphx_glr_auto_examples_tree_plot_cost_complexity_pruning.py`
    for an example of such pruning.

    .. versionadded:: 0.22

monotonic_cst : array-like of int of shape (n_features), default=None
    Indicates the monotonicity constraint to enforce on each feature.
      - 1: monotonic increase
      - 0: no constraint
      - -1: monotonic decrease

    If monotonic_cst is None, no constraints are applied.

    Monotonicity constraints are not supported for:
      - multiclass classifications (i.e. when `n_classes > 2`),
      - multioutput classifications (i.e. when `n_outputs_ > 1`),
      - classifications trained on data with missing values.

    The constraints hold over the probability of the positive class.

    Read more in the :ref:`User Guide <monotonic_cst_gbdt>`.

    .. versionadded:: 1.4

Attributes
----------
classes_ : ndarray of shape (n_classes,) or list of ndarray
    The classes labels (single output problem),
    or a list of arrays of class labels (multi-output problem).

max_features_ : int
    The inferred value of max_features.

n_classes_ : int or list of int
    The number of classes (for single output problems),
    or a list containing the number of classes for each
    output (for multi-output problems).

feature_importances_ : ndarray of shape (n_features,)
    The impurity-based feature importances.
    The higher, the more important the feature.
    The importance of a feature is computed as the (normalized)
    total reduction of the criterion brought by that feature.  It is also
    known as the Gini importance.

    Warning: impurity-based feature importances can be misleading for
    high cardinality features (many unique values). See
    :func:`sklearn.inspection.permutation_importance` as an alternative.

n_features_in_ : int
    Number of features seen during :term:`fit`.

    .. versionadded:: 0.24

feature_names_in_ : ndarray of shape (`n_features_in_`,)
    Names of features seen during :term:`fit`. Defined only when `X`
    has feature names that are all strings.

    .. versionadded:: 1.0

n_outputs_ : int
    The number of outputs when ``fit`` is performed.

tree_ : Tree instance
    The underlying Tree object. Please refer to
    ``help(sklearn.tree._tree.Tree)`` for attributes of Tree object and
    :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py`
    for basic usage of these attributes.

See Also
--------
ExtraTreeRegressor : An extremely randomized tree regressor.
sklearn.ensemble.ExtraTreesClassifier : An extra-trees classifier.
sklearn.ensemble.ExtraTreesRegressor : An extra-trees regressor.
sklearn.ensemble.RandomForestClassifier : A random forest classifier.
sklearn.ensemble.RandomForestRegressor : A random forest regressor.
sklearn.ensemble.RandomTreesEmbedding : An ensemble of
    totally random trees.

Notes
-----
The default values for the parameters controlling the size of the trees
(e.g. ``max_depth``, ``min_samples_leaf``, etc.) lead to fully grown and
unpruned trees which can potentially be very large on some data sets. To
reduce memory consumption, the complexity and size of the trees should be
controlled by setting those parameter values.

References
----------

.. [1] P. Geurts, D. Ernst., and L. Wehenkel, "Extremely randomized trees",
       Machine Learning, 63(1), 3-42, 2006.

Examples
--------
>>> from sklearn.datasets import load_iris
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.ensemble import BaggingClassifier
>>> from sklearn.tree import ExtraTreeClassifier
>>> X, y = load_iris(return_X_y=True)
>>> X_train, X_test, y_train, y_test = train_test_split(
...    X, y, random_state=0)
>>> extra_tree = ExtraTreeClassifier(random_state=0)
>>> cls = BaggingClassifier(extra_tree, random_state=0).fit(
...    X_train, y_train)
>>> cls.score(X_test, y_test)
0.8947
r0   r9   Nr
   r    r@   rE   r  c                8   > [         TU ]  UUUUUUUU	UU
UUUS9  g )N)rV   rH   rI   rJ   rK   rL   rM   rN   rS   rO   rG   rP   rQ   r  r  s                 rX   rY   ExtraTreeClassifier.__init__  s>    " 	/-%=%)%"7%' 	 	
r[   c                    > [         TU ]  5       nU R                  S:H  =(       a    U R                  S;   nSUR                  l        X!R                  l        U$ )Nr9   >   r0   r2   r1   Tr  r  s      rX   rf   $ExtraTreeClassifier.__sklearn_tags__  sU    w') MMX- 
$.. E
 3
	
 ,0($-!r[   r   	rs   r   r   r   r   rY   rf   r   r   r  s   @rX   r.   r.     sH    oh !$!
 
B r[   r.   c                   V   ^  \ rS rSrSrSSSSSSS	SSSSSS
.U 4S jjrU 4S jrSrU =r$ )r/   i  aO   An extremely randomized tree regressor.

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 :ref:`User Guide <tree>`.

Parameters
----------
criterion : {"squared_error", "friedman_mse", "absolute_error", "poisson"},             default="squared_error"
    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 Poisson deviance to find splits.

    .. versionadded:: 0.18
       Mean Absolute Error (MAE) criterion.

    .. versionadded:: 0.24
        Poisson deviance criterion.

splitter : {"random", "best"}, default="random"
    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.

max_depth : int, default=None
    The maximum depth of the tree. If None, then nodes are expanded until
    all leaves are pure or until all leaves contain less than
    min_samples_split samples.

min_samples_split : int or float, default=2
    The minimum number of samples required to split an internal node:

    - If int, then consider `min_samples_split` as the minimum number.
    - If float, then `min_samples_split` is a fraction and
      `ceil(min_samples_split * n_samples)` are the minimum
      number of samples for each split.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_samples_leaf : int or float, default=1
    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.

    - If int, then consider `min_samples_leaf` as the minimum number.
    - If float, then `min_samples_leaf` is a fraction and
      `ceil(min_samples_leaf * n_samples)` are the minimum
      number of samples for each node.

    .. versionchanged:: 0.18
       Added float values for fractions.

min_weight_fraction_leaf : float, default=0.0
    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.

max_features : int, float, {"sqrt", "log2"} or None, default=1.0
    The number of features to consider when looking for the best split:

    - If int, then consider `max_features` features at each split.
    - If float, then `max_features` is a fraction and
      `max(1, int(max_features * n_features_in_))` features are considered at each
      split.
    - If "sqrt", then `max_features=sqrt(n_features)`.
    - If "log2", then `max_features=log2(n_features)`.
    - If None, then `max_features=n_features`.

    .. versionchanged:: 1.1
        The default of `max_features` changed from `"auto"` to `1.0`.

    Note: the search for a split does not stop until at least one
    valid partition of the node samples is found, even if it requires to
    effectively inspect more than ``max_features`` features.

random_state : int, RandomState instance or None, default=None
    Used to pick randomly the `max_features` used at each split.
    See :term:`Glossary <random_state>` for details.

min_impurity_decrease : float, default=0.0
    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::

        N_t / N * (impurity - N_t_R / N_t * right_impurity
                            - N_t_L / N_t * left_impurity)

    where ``N`` is the total number of samples, ``N_t`` is the number of
    samples at the current node, ``N_t_L`` is the number of samples in the
    left child, and ``N_t_R`` is the number of samples in the right child.

    ``N``, ``N_t``, ``N_t_R`` and ``N_t_L`` all refer to the weighted sum,
    if ``sample_weight`` is passed.

    .. versionadded:: 0.19

max_leaf_nodes : int, default=None
    Grow a tree with ``max_leaf_nodes`` in best-first fashion.
    Best nodes are defined as relative reduction in impurity.
    If None then unlimited number of leaf nodes.

ccp_alpha : non-negative float, default=0.0
    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
    :ref:`minimal_cost_complexity_pruning` for details. See
    :ref:`sphx_glr_auto_examples_tree_plot_cost_complexity_pruning.py`
    for an example of such pruning.

    .. versionadded:: 0.22

monotonic_cst : array-like of int of shape (n_features), default=None
    Indicates the monotonicity constraint to enforce on each feature.
      - 1: monotonic increase
      - 0: no constraint
      - -1: monotonic decrease

    If monotonic_cst is None, no constraints are applied.

    Monotonicity constraints are not supported for:
      - multioutput regressions (i.e. when `n_outputs_ > 1`),
      - regressions trained on data with missing values.

    Read more in the :ref:`User Guide <monotonic_cst_gbdt>`.

    .. versionadded:: 1.4

Attributes
----------
max_features_ : int
    The inferred value of max_features.

n_features_in_ : int
    Number of features seen during :term:`fit`.

    .. versionadded:: 0.24

feature_names_in_ : ndarray of shape (`n_features_in_`,)
    Names of features seen during :term:`fit`. Defined only when `X`
    has feature names that are all strings.

    .. versionadded:: 1.0

feature_importances_ : ndarray of shape (n_features,)
    Return impurity-based feature importances (the higher, the more
    important the feature).

    Warning: impurity-based feature importances can be misleading for
    high cardinality features (many unique values). See
    :func:`sklearn.inspection.permutation_importance` as an alternative.

n_outputs_ : int
    The number of outputs when ``fit`` is performed.

tree_ : Tree instance
    The underlying Tree object. Please refer to
    ``help(sklearn.tree._tree.Tree)`` for attributes of Tree object and
    :ref:`sphx_glr_auto_examples_tree_plot_unveil_tree_structure.py`
    for basic usage of these attributes.

See Also
--------
ExtraTreeClassifier : An extremely randomized tree classifier.
sklearn.ensemble.ExtraTreesClassifier : An extra-trees classifier.
sklearn.ensemble.ExtraTreesRegressor : An extra-trees regressor.

Notes
-----
The default values for the parameters controlling the size of the trees
(e.g. ``max_depth``, ``min_samples_leaf``, etc.) lead to fully grown and
unpruned trees which can potentially be very large on some data sets. To
reduce memory consumption, the complexity and size of the trees should be
controlled by setting those parameter values.

References
----------

.. [1] P. Geurts, D. Ernst., and L. Wehenkel, "Extremely randomized trees",
       Machine Learning, 63(1), 3-42, 2006.

Examples
--------
>>> from sklearn.datasets import load_diabetes
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.ensemble import BaggingRegressor
>>> from sklearn.tree import ExtraTreeRegressor
>>> X, y = load_diabetes(return_X_y=True)
>>> X_train, X_test, y_train, y_test = train_test_split(
...     X, y, random_state=0)
>>> extra_tree = ExtraTreeRegressor(random_state=0)
>>> reg = BaggingRegressor(extra_tree, random_state=0).fit(
...     X_train, y_train)
>>> reg.score(X_test, y_test)
0.33
r3   r9   Nr
   r    r@   rA   )rV   rH   rI   rJ   rK   rL   rM   rG   rO   rN   rP   rQ   c                6   > [         TU ]  UUUUUUUU
U	UUUS9  g )N)rV   rH   rI   rJ   rK   rL   rM   rN   rO   rG   rP   rQ   r  )rW   rV   rH   rI   rJ   rK   rL   rM   rG   rO   rN   rP   rQ   rr   s                rX   rY   ExtraTreeRegressor.__init__  s;      	/-%=%)"7%' 	 	
r[   c                    > [         TU ]  5       nU R                  S:H  =(       a    U R                  S;   nX!R                  l        U$ )Nr9   >   r6   r4   r3   r3  r  s      rX   rf   #ExtraTreeRegressor.__sklearn_tags__  sG    w') MMX- 
$.. E
 3
	
 %.!r[   r   r;  r  s   @rX   r/   r/     sD    Sp "!$!
 
>
 
r[   r/   )Mr   r   r   abcr   r   mathr   r   r   numpyru   scipy.sparser   sklearn.utilsr	   baser   r   r   r   r   r   r   utilsr   r   r   utils._param_validationr   r   r   r   utils.multiclassr   utils.validationr   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   _utilsr+   __all__r   r   GiniEntropyr   MSEFriedmanMSEMAEPoissonr   BestSplitterRandomSplitterr   BestSparseSplitterRandomSparseSplitterr   r;   r,   r-   r.   r/   r   r[   rX   <module>rX     s]     '  "  ! *   E D N N ;  + * !   % 		 OO""!!  ^^** nn!!	 %11Y=U=UV ((,, ]	'' ]	JT_.> TnSN,< Sl
^0 ^B	. r[   