
    0Ph/                       d Z ddlZddlZddlmZmZ ddlmZ ddlmZm	Z	 ddl
ZddlmZ ddlmZ dd	lmZmZmZmZmZmZmZ dd
lmZmZmZ ddlmZmZmZm Z  ddl!m"Z" ddl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+m,Z,m-Z- ddl+m.Z. ddl,m/Z/ ddl-m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 g dZ7e-j8        Z8e-j9        Z9e+j:        e+j;        e+j;        dZ<e+j=        e+j>        e+j?        e+j@        dZAe,jB        e,jC        dZDe,jE        e,jF        dZG G d deee          ZH G d deeH          ZI G d deeH          ZJ G d d eI          ZK G d! d"eJ          ZLdS )#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                   V    e Zd ZU dZdej        iZ eddh          g ee	ddd          dg ee	d	dd           ee
d
dd          g ee	ddd           ee
d
dd          g eed
dd          g ee	ddd           ee
d
dd           eddh          dgdg ee	d	dd          dg eed
dd          g eed
dd          gddgdZeed<   edd
ddd            Zd Zd Zd Zd&dZ	 	 	 d'dZd Zd(dZd(d Zd(d!Zd" Zd&d#Zed$             Z fd%Z xZS ))BaseDecisionTreezzBase 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_featuresrF   max_leaf_nodesmin_impurity_decrease	ccp_alphamonotonic_cst_parameter_constraints)class_weightrO   rP   c                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        || _
        || _        || _        d S N)	criterionrG   rH   rI   rJ   rK   rL   rM   rF   rN   rR   rO   rP   )selfrU   rG   rH   rI   rJ   rK   rL   rM   rF   rN   rR   rO   rP   s                 U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/tree/_classes.py__init__zBaseDecisionTree.__init__   sn    $ # "!2 0(@%(,(%:"("*    c                 8    t          |            | j        j        S )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_rH   rV   s    rW   	get_depthzBaseDecisionTree.get_depth   s     	z##rY   c                 8    t          |            | j        j        S )zReturn the number of leaves of the decision tree.

        Returns
        -------
        self.tree_.n_leaves : int
            Number of leaves.
        )r   r[   n_leavesr\   s    rW   get_n_leaveszBaseDecisionTree.get_n_leaves   s     	z""rY   c                 p    t          |           o&|                                 j        j        o| j        d u S rT   )r   __sklearn_tags__
input_tags	allow_nanrP   )rV   Xs     rW   _support_missing_valuesz(BaseDecisionTree._support_missing_values   s<    O +%%''2<+"d*	
rY   c                    |p| j         j        }t          |d          }|                     |          st	          |fi | dS t          j        d          5  t          j        |          }ddd           n# 1 swxY w Y   t          j        |          st          |ft
          dd| t          j
        |          sdS t          |          }|S )ax  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.
        re   )estimator_name
input_nameNignore)overT)xprd   )	__class____name__dictrf   r   nperrstatesumisfiniter   isnanr+   )rV   re   rh   common_kwargsoverall_summissing_values_in_feature_masks         rW   '_compute_missing_values_in_feature_maskz8BaseDecisionTree._compute_missing_values_in_feature_mask   s*   & (B4>+BNsKKK++A.. 	a11=1114[h''' 	$ 	$&))K	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ {;'' 	W+AV"VVVVV x$$ 	4)9!)<)<&--s   A::A>A>Tc           	         t          | j                  }|rt          t          dd          }t          dd           }t	          | ||||f          \  }}|                     |          }t          |          rW|                                 |j        j	        t          j        k    s|j        j	        t          j        k    rt          d          | j        dk    rNt          j        |dk               rt          d	          t          j        |          dk    rt          d
          |j        \  }	| _        t'          |           }
t          j        |          }d }|j        dk    rt          j        |d          }|j        d         | _        |
r4t1          |           t          j        |          }g | _        g | _        | j        t          j        |          }t          j        |j        t<                    }t?          | j                  D ]k}t          j         |d d |f         d          \  }|d d |f<   | j        !                    |           | j        !                    |j        d                    l|}| j        tE          | j        |          }t          j#        | j        t          j$                  | _        tK          |dd           tL          k    s|j'        j(        st          j)        |tL                    }| j*        #t          j+        t          j,                  j-        n| j*        }t]          | j/        t`          j1                  r| j/        }n$t=          te          | j/        |	z                      }t]          | j3        t`          j1                  r| j3        }n4t=          te          | j3        |	z                      }t[          d|          }t[          |d|z            }t]          | j4        tj                    r| j4        dk    r5t[          dt=          t          j6        | j                                      }n| j4        dk    r4t[          dt=          t          j7        | j                                      }nn| j4        | j        }n_t]          | j4        t`          j1                  r| j4        }n8| j4        dk    r+t[          dt=          | j4        | j        z                      }nd}|| _8        | j9        dn| j9        }tu          |          |	k    r!t          dtu          |          |	fz            |tw          ||tL                    }|
|||z  }n|}|| j<        |	z  }n| j<        t          j        |          z  }| j        }t]          |tz                    sI|
r&t}          | j                 | j        | j                  }n5t          | j                 | j        |	          }nt3          j@        |          }t          |          rt          nt          }| jC        }| jD        d }n+| j        dk    rt          d          t          jE        | jD                  }|j        d         |j        d         k    r9t          dF                    |j        d         |j        d                             t          jG        |d          }t          jH        |          s&t          j         |          }t          d|           t          jE        |t          jI                  }t'          |           r%| j        d         dk    rt          d          |dz  }t]          | jC        t                    s  || jC                 || j8        ||||          }t'          |           r&t          | j        | j        | j                  | _L        nGt          | j        t          j#        dg| j        z  t          j$                  | j                  | _L        |dk     rt          |||||| jN                  }nt          ||||||| jN                  }|P                    | jL        ||||           | j        dk    r3t'          |           r$| j        d         | _        | j        d         | _        | Q                                 | S )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
   rD   rE   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   rF   ro   DTYPEr   rx   r   sort_indicesindicesr{   rp   intcindptr
ValueErrorrU   anyrr   shapen_features_in_r   
atleast_1dndimreshape
n_outputs_r   copyclasses_
n_classes_rR   zerosintrangeuniqueappendr   arrayintpgetattrDOUBLEflags
contiguousascontiguousarrayrH   iinfoint32max
isinstancerJ   numbersr   r   rI   rL   strrD   rE   max_features_rM   lenr   rK   r$   CRITERIA_CLFCRITERIA_REGdeepcopySPARSE_SPLITTERSDENSE_SPLITTERSrG   rP   asarrayformatisinallint8r%   r(   r[   r'   rN   r&   build_prune_tree)rV   re   ysample_weightr<   rw   rF   check_X_paramscheck_y_params	n_samplesis_classificationexpanded_class_weight
y_original	y_encodedk	classes_krH   rJ   rI   rL   rM   min_weight_leafrU   	SPLITTERSrG   rP   valid_constraintsunique_constaints_valuebuilders                                rW   _fitzBaseDecisionTree._fit   s    *$*;<< $	 "5E  N "E>>>N a0P  DAq
 <<Q?? + {{    9?bg--271J1J$M   ~**6!a%== $?   6!99>>$<   *+&	4&)$//M! $6Q;; 
1g&&A'!* 	G(+++

ADM DO ,WQZZ
444I4?++ ; ;-/YqAwt-T-T-T*	9QQQT?$$Y///&&yq'9::::A ,(=%z) )% !htbgFFFDO1gt$$..ag6H.$Qf555A.2n.DBHRX&&**$.	d+W-=>> 	L#4"4(=	(I#J#JKKd,g.>?? 	: $ 6 #D)?))K$L$L M M #A'8 9 9 117G3GHHd'-- 	! F**"1c"'$2E*F*F&G&GHH"f,,"1c"'$2E*F*F&G&GHH&.LL)7+;<< 	!,LL 3&&"1c$*;d>Q*Q&R&RSS )#2:@Sq66YIq669%&  
 $06JJM ,( -0E E 5  ";iGOO";bf]>S>SSO N	)Y// 
	1  U(8OT_ 		 )8)TT		 i00I(0H$$	=% MM"" W   Jt'9::M"1%33 ))/0CA0FPQ
)S)S   !#z B B6+,, *,)M*B*B' 636 6   J}BGDDDMT"" $?1%))$)   #$-22 	/y/"  H  	d14?DOTTDJJ#!t.bg>>>	 DJ A+! * GG +! * G 	dj!Q7UVVV?aM$$7$7"oa0DO M!,DMrY   c                 <   |r|                      |          rd}nd}t          | |t          dd|          }t          |          rC|j        j        t          j        k    s|j        j        t          j        k    rt          d          nt          | |d           |S )z6Validate the training data on predict (probabilities).z	allow-nanTcsrF)r{   r|   resetr}   r   )r   )rf   r   r   r   r   r{   rp   r   r   r   r   )rV   re   r<   r}   s       rW   _validate_X_predictz$BaseDecisionTree._validate_X_predict  s     	4++A.. )$/!!$(!#"3  A {{ X	27**ahn.G.G !VWWW dAU3333rY   c                    t          |            |                     ||          }| j                            |          }|j        d         }t          |           r| j        dk    r0| j                            t          j
        |d          d          S | j        d         j        }t          j        || j        f|          }t          | j                  D ]I}| j        |                             t          j
        |dd|f         d          d          |dd|f<   J|S | j        dk    r|dddf         S |dddddf         S )aG  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   takerp   argmaxr{   r   r   )rV   re   r<   probar   
class_typepredictionsr   s           rW   r   zBaseDecisionTree.predict  si   . 	$$Q44
""1%%GAJ	  	&!##}))")E*B*B*B)KKK "]1-3
 h	4?'C:VVVt//  A(,a(8(=(=	%1+A666Q )> ) )K1%% #" !##QQQT{" QQQ1W~%rY   c                     t          |            |                     ||          }| j                            |          S )aW  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rV   re   r<   s      rW   r   zBaseDecisionTree.apply-  s=    0 	$$Q44z"""rY   c                 b    |                      ||          }| j                            |          S )a  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      rW   r   zBaseDecisionTree.decision_pathI  s/    , $$Q44z''***rY   c                    t          |            | j        dk    rdS t          |           r5t          j        | j                  }t          | j        || j                  }nBt          | j        t          j	        dg| j        z  t          j
                  | j                  }t          || j        | j                   || _        dS )z1Prune tree using Minimal Cost-Complexity Pruning.r?   Nr    r   )r   rO   r   rp   r   r   r(   r   r   r   r   r)   r[   )rV   	n_classespruned_trees      rW   r   zBaseDecisionTree._prune_treeb  s    >S  F  		do66It2ItOOKK#!t.bg>>>	 K 	{DJGGG 


rY   c                     t          |                               d          }|                    |||           t          di t	          |j                  S )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?   )rO   )r    )r   
set_paramsfitr   r*   r[   )rV   re   r   r   ests        rW   cost_complexity_pruning_pathz-BaseDecisionTree.cost_complexity_pruning_pathx  sX    F Dkk$$s$331M22233'	22333rY   c                 R    t          |            | j                                        S )ap  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    rW   feature_importances_z%BaseDecisionTree.feature_importances_  s&    $ 	z55777rY   c                 `    t                                                      }d|j        _        |S NT)superrb   rc   sparse)rV   tagsrm   s     rW   rb   z!BaseDecisionTree.__sklearn_tags__  s'    ww''))!%rY   rT   )NTNT) rn   
__module____qualname____doc__r	   UNUSED,_BaseDecisionTree__metadata_request__predictr   r   r   r   r   rQ   ro   __annotations__r   rX   r]   r`   rf   rx   r   r   r   r   r   r   r   propertyr   rb   __classcell__rm   s   @rW   r;   r;   [   s          $12B2I"J  Z 2334hxD@@@$GHXq$v666HZc':::

 HXq$v666HZc)<<<
 &.XdCV%L%L%L$MHXq$v666HZc':::J'((	
 ((#8HafEEEtL"*(4d6"J"J"J!KhtS$v>>>?&--$ $D   2  + + + + ^+>$ $ $	# 	# 	#
 
 
&. &. &. &.X '+y y y yv  01& 1& 1& 1&f# # # #8+ + + +2! ! !,%4 %4 %4 %4N 8 8 X8*        rY   r;   )	metaclassc                       e Zd ZU dZdej        iZdej        iZi ej	         e
h d           ee          gee e
dh          dgdZ	eed<   dd	dd
dddddddddd fd
Z ed          d fd	            ZddZd Z fdZ xZS )r,   ap)  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)rU   rR   rQ   r0   r8   r
   r    r?   rU   rG   rH   rI   rJ   rK   rL   rF   rM   rN   rR   rO   rP   c                d    t                                          ||||||||	|||
||           d S )N)rU   rG   rH   rI   rJ   rK   rL   rM   rR   rF   rN   rP   rO   r   rX   rV   rU   rG   rH   rI   rJ   rK   rL   rF   rM   rN   rR   rO   rP   rm   s                 rW   rX   zDecisionTreeClassifier.__init__  sW    " 	/-%=%)%%"7' 	 	
 	
 	
 	
 	
rY   Tprefer_skip_nested_validationc                 R    t                                          ||||           | S )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   rV   re   r   r   r<   rm   s        rW   r   zDecisionTreeClassifier.fit  s7    > 	'#	 	 	
 	
 	
 rY   c                 P   t          |            |                     ||          }| j                            |          }| j        dk    r|ddd| j        f         S g }t          | j                  D ]1}|dd|d| j        |         f         }|                    |           2|S )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   )rV   re   r<   r   	all_probar   proba_ks          rW   predict_probaz$DecisionTreeClassifier.predict_proba  s    0 	$$Q44
""1%%?a-do--..I4?++ * *1&:(:&: :;  ))))rY   c                     |                      |          }| j        dk    rt          j        |          S t	          | j                  D ]}t          j        ||                   ||<    |S )a  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   rp   logr   )rV   re   r   r   s       rW   predict_log_probaz(DecisionTreeClassifier.predict_log_proba-  sk    " ""1%%?a6%==  4?++ , ,6%(++aLrY   c                     t                                                      }| j        dv o| j        dv }d|j        _        ||j        _        |S )Nr7   r   Tr   rb   rG   rU   classifier_tagsmulti_labelrc   rd   rV   r   rd   rm   s      rW   rb   z'DecisionTreeClassifier.__sklearn_tags__I  sW    ww'')) M%77 
DN O
 =
	
 ,0($-!rY   r   r   )rn   r   r   r   r	   r   8_DecisionTreeClassifier__metadata_request__predict_proba._DecisionTreeClassifier__metadata_request__fitr;   rQ   r   r   r$   ro   listr   rX   r   r   r  r  rb   r   r   s   @rW   r,   r,     s        r rl *78H8O(P%,.>.EF$

1$ j!@!@!@AA66)CTCTUtZZ%=%=tD$ $ $D    !$!
 
 
 
 
 
 
B \555$ $ $ $ $ 65$L# # # #J  8        rY   r,   c                        e Zd ZU dZdej        iZi ej        d e	h d           e
e          giZeed<   dddd	d
dddddddd fd
Z ed          d fd	            Zd Z fdZ xZS )r-   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<   rU   >   r6   r4   r3   r5   rQ   r3   r8   Nr
   r    r?   )rU   rG   rH   rI   rJ   rK   rL   rF   rM   rN   rO   rP   c                b    t                                          ||||||||	||
||           d S )N)rU   rG   rH   rI   rJ   rK   rL   rM   rF   rN   rO   rP   r   )rV   rU   rG   rH   rI   rJ   rK   rL   rF   rM   rN   rO   rP   rm   s                rW   rX   zDecisionTreeRegressor.__init__?  sT      	/-%=%)%"7' 	 	
 	
 	
 	
 	
rY   Tr   c                 R    t                                          ||||           | S )aa  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        rW   r   zDecisionTreeRegressor.fit^  s7    < 	'#	 	 	
 	
 	
 rY   c                    t          j        |t          d          }t          j        |j        d         t           j        d          }t          j        |t           j        d          }| j                            |||           |S )av  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  )	rp   r   r   r   r   float64r   r[   compute_partial_dependence)rV   gridtarget_featuresaveraged_predictionss       rW   %_compute_partial_dependence_recursionz;DecisionTreeRegressor._compute_partial_dependence_recursion  s    " z$e3777!x*Q-rz 
  
  
 *_BG3OOO
--/#7	
 	
 	
 $#rY   c                     t                                                      }| j        dv o| j        dv }||j        _        |S )Nr7      r6   r4   r3   )r   rb   rG   rU   rc   rd   r
  s      rW   rb   z&DecisionTreeRegressor.__sklearn_tags__  sL    ww'')) M%77 
DN O
 =
	
 %.!rY   r   )rn   r   r   r   r	   r   -_DecisionTreeRegressor__metadata_request__fitr;   rQ   r   r   r$   ro   r   rX   r   r   r  rb   r   r   s   @rW   r-   r-   W  s@        Y Yz  -.>.EF$

1$JUUUVVF9
$ $D    "!$!
 
 
 
 
 
 
> \555# # # # # 65#J$ $ $8
 
 
 
 
 
 
 
 
rY   r-   c                   J     e Zd ZdZdddddddddddddd	 fd

Z fdZ xZS )r.   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?   rD   r   c                d    t                                          ||||||||	||
|||           d S )N)rU   rG   rH   rI   rJ   rK   rL   rM   rR   rN   rF   rO   rP   r   r   s                 rW   rX   zExtraTreeClassifier.__init__  sW    " 	/-%=%)%"7%' 	 	
 	
 	
 	
 	
rY   c                     t                                                      }| j        dk    o| j        dv }d|j        _        ||j        _        |S )Nr9   r   Tr  r
  s      rW   rb   z$ExtraTreeClassifier.__sklearn_tags__  sV    ww'')) MX- 
$. E
 3
	
 ,0($-!rY   rn   r   r   r   rX   rb   r   r   s   @rW   r.   r.     s        o oh !$!
 
 
 
 
 
 
B        rY   r.   c                   H     e Zd ZdZddddddddddddd	 fd

Z fdZ xZS )r/   a"  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?   r@   )rU   rG   rH   rI   rJ   rK   rL   rF   rN   rM   rO   rP   c                b    t                                          ||||||||
|	|||           d S )N)rU   rG   rH   rI   rJ   rK   rL   rM   rN   rF   rO   rP   r   )rV   rU   rG   rH   rI   rJ   rK   rL   rF   rN   rM   rO   rP   rm   s                rW   rX   zExtraTreeRegressor.__init__  sT      	/-%=%)"7%' 	 	
 	
 	
 	
 	
rY   c                 ~    t                                                      }| j        dk    o| j        dv }|j         |S )Nr9   r  )r   rb   rG   rU   rc   r
  s      rW   rb   z#ExtraTreeRegressor.__sklearn_tags__  sI    ww'')) MX- 
$. E
 3
	
 	,rY   r   r   s   @rW   r/   r/     s        S Sp "!$!
 
 
 
 
 
 
>
 
 
 
 
 
 
 
 
rY   r/   )Mr   r   r   abcr   r   mathr   r   r   numpyrp   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   rY   rW   <module>r;     s      ' ' ' ' ' ' ' '       " " " " " " " "     ! ! ! ! ! ! * * * * * *                  E D D D D D D D D D N N N N N N N N N N N N ; ; ; ; ; ;                + * * * * * * * * * ! ! ! ! ! !                    % $ $ $ $ $   		 O"!   ^* n!	  %1Y=UVV (,  ]	 ]	 ]	 ]	 ]	'' ]	 ]	 ]	 ]	JT T T T T_.> T T TnS S S S SN,< S S Sl
^ ^ ^ ^ ^0 ^ ^ ^B	    .     rY   