
    -i                     J   S r SSKrSSKJr  SSKJr  SSKrSSKJ	r	  SSK
JrJrJrJrJr  SSKJr  SS	KJr  SS
KJr  SSKJrJr  SSK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&J'r'  SSK(J)r)J*r*  SSK+J,r,J-r-J.r.J/r/J0r0  SSK1J2r2J3r3  S r4 " S S\2\\5      r5 " S S\55      r6g)z1Recursive feature elimination for feature ranking    N)deepcopy)Integral)effective_n_jobs   )BaseEstimatorMetaEstimatorMixin_fit_contextcloneis_classifier)
get_scorer)check_cv_score)Bunchmetadata_routing)MetadataRouterMethodMapping_raise_for_params_routing_enabledprocess_routing)
HasMethodsInterval
RealNotInt)get_tags)_safe_splitavailable_if)Paralleldelayed)_check_method_params_deprecate_positional_args_estimator_hascheck_is_fittedvalidate_data   )SelectorMixin_get_feature_importancesc                 R  ^^^^ [        XX45      u  p[        XX5U5      u  mm[        X'R                  R                  US9n
[        X'R                  R
                  US9mU R                  " UU	UUUU4S j40 U
D6  U R                  U R                  U R                  U R                  4$ )zE
Return the score and n_features per step for a fit across one fold.
)paramsindices)Xr(   r)   c                 ,   > [        U TS S 2U4   TTTS9$ )N)score_paramsr   )	estimatorfeaturesX_testr,   scorery_tests     Q/var/www/html/venv/lib/python3.13/site-packages/sklearn/feature_selection/_rfe.py<lambda>!_rfe_single_fit.<locals>.<lambda>7   s"    F1h;%%
    )r   r   r-   fitr0   score_fitstep_scores_step_support_step_ranking_step_n_features_)rfer-   r*   ytraintestr0   routed_paramsX_trainy_train
fit_paramsr/   r,   r1   s         `    @@@r2   _rfe_single_fitrE   '   s     #9:G q>NFF%	))--uJ (
((..L HH	
  S..0A0A3CWCWWWr5   c            
         ^  \ rS rSr% Sr\" S/5      /S\" \SSSS9\" \SSS	S9/\" \SSS	S9\" \SSS	S9/S
/\	\
/S.r\\S'   SSSSS.S jr\S 5       r\S 5       r\" SS9S 5       rS$S jr\" \" S5      5      S 5       r\" \" S5      5      S 5       rS r\" \" S5      5      S 5       r\" \" S5      5      S 5       r\" \" S5      5      S  5       rU 4S! jrS" rS#rU =r $ )%RFED   a  Feature ranking with recursive feature elimination.

Given an external estimator that assigns weights to features (e.g., the
coefficients of a linear model), the goal of recursive feature elimination
(RFE) is to select features by recursively considering smaller and smaller
sets of features. First, the estimator is trained on the initial set of
features and the importance of each feature is obtained either through
any specific attribute or callable.
Then, the least important features are pruned from current set of features.
That procedure is recursively repeated on the pruned set until the desired
number of features to select is eventually reached.

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

Parameters
----------
estimator : ``Estimator`` instance
    A supervised learning estimator with a ``fit`` method that provides
    information about feature importance
    (e.g. `coef_`, `feature_importances_`).

n_features_to_select : int or float, default=None
    The number of features to select. If `None`, half of the features are
    selected. If integer, the parameter is the absolute number of features
    to select. If float between 0 and 1, it is the fraction of features to
    select.

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

step : int or float, default=1
    If greater than or equal to 1, then ``step`` corresponds to the
    (integer) number of features to remove at each iteration.
    If within (0.0, 1.0), then ``step`` corresponds to the percentage
    (rounded down) of features to remove at each iteration.

verbose : int, default=0
    Controls verbosity of output.

importance_getter : str or callable, default='auto'
    If 'auto', uses the feature importance either through a `coef_`
    or `feature_importances_` attributes of estimator.

    Also accepts a string that specifies an attribute name/path
    for extracting feature importance (implemented with `attrgetter`).
    For example, give `regressor_.coef_` in case of
    :class:`~sklearn.compose.TransformedTargetRegressor`  or
    `named_steps.clf.feature_importances_` in case of
    class:`~sklearn.pipeline.Pipeline` with its last step named `clf`.

    If `callable`, overrides the default feature importance getter.
    The callable is passed with the fitted estimator and it should
    return importance for each feature.

    .. versionadded:: 0.24

Attributes
----------
classes_ : ndarray of shape (n_classes,)
    The classes labels. Only available when `estimator` is a classifier.

estimator_ : ``Estimator`` instance
    The fitted estimator used to select features.

n_features_ : int
    The number of selected features.

n_features_in_ : int
    Number of features seen during :term:`fit`. Only defined if the
    underlying estimator exposes such an attribute when 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

ranking_ : ndarray of shape (n_features,)
    The feature ranking, such that ``ranking_[i]`` corresponds to the
    ranking position of the i-th feature. Selected (i.e., estimated
    best) features are assigned rank 1.

support_ : ndarray of shape (n_features,)
    The mask of selected features.

See Also
--------
RFECV : Recursive feature elimination with built-in cross-validated
    selection of the best number of features.
SelectFromModel : Feature selection based on thresholds of importance
    weights.
SequentialFeatureSelector : Sequential cross-validation based feature
    selection. Does not rely on importance weights.

Notes
-----
Allows NaN/Inf in the input if the underlying estimator does as well.

References
----------

.. [1] Guyon, I., Weston, J., Barnhill, S., & Vapnik, V., "Gene selection
       for cancer classification using support vector machines",
       Mach. Learn., 46(1-3), 389--422, 2002.

Examples
--------
The following example shows how to retrieve the 5 most informative
features in the Friedman #1 dataset.

>>> from sklearn.datasets import make_friedman1
>>> from sklearn.feature_selection import RFE
>>> from sklearn.svm import SVR
>>> X, y = make_friedman1(n_samples=50, n_features=10, random_state=0)
>>> estimator = SVR(kernel="linear")
>>> selector = RFE(estimator, n_features_to_select=5, step=1)
>>> selector = selector.fit(X, y)
>>> selector.support_
array([ True,  True,  True,  True,  True, False, False, False, False,
       False])
>>> selector.ranking_
array([1, 1, 1, 1, 1, 6, 4, 3, 2, 5])
r6   Nr   r$   rightclosedneitherverbose)r-   n_features_to_selectsteprM   importance_getter_parameter_constraintsauto)rN   rO   rM   rP   c                @    Xl         X l        X0l        XPl        X@l        g Nr-   rN   rO   rP   rM   )selfr-   rN   rO   rM   rP   s         r2   __init__RFE.__init__   s     #$8!	!2r5   c                 .    U R                   R                  $ rT   )r-   _estimator_typerV   s    r2   rZ   RFE._estimator_type   s    ~~---r5   c                 .    U R                   R                  $ )zjClasses labels available when `estimator` is a classifier.

Returns
-------
ndarray of shape (n_classes,)
)
estimator_classes_r[   s    r2   r_   RFE.classes_   s     '''r5   Fprefer_skip_nested_validationc                     [        5       (       a  [        U S40 UD6nO[        [        US9S9nU R                  " X40 UR                  R
                  D6$ )a  Fit the RFE model and then the underlying estimator on the selected features.

Parameters
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features)
    The training input samples.

y : array-like of shape (n_samples,)
    The target values.

**fit_params : dict
    - If `enable_metadata_routing=False` (default): Parameters directly passed
      to the ``fit`` method of the underlying estimator.

    - If `enable_metadata_routing=True`: Parameters safely routed to the ``fit``
      method of the underlying estimator.

    .. versionchanged:: 1.6
        See :ref:`Metadata Routing User Guide <metadata_routing>`
        for more details.

Returns
-------
self : object
    Fitted estimator.
r6   r6   r-   )r   r   r   r8   r-   r6   )rV   r*   r>   rD   rA   s        r2   r6   RFE.fit   sM    > +D%F:FM!Ej,ABMyy=!8!8!<!<==r5   c           
      J   [        U UUSSSSS9u  pUR                  S   nU R                  c  US-  nOl[        U R                  [        5      (       a6  U R                  nXe:  a$  [
        R                  " SU< SU< S	3[        5        O[        XPR                  -  5      nS
U R                  s=:  a  S:  a&  O  O#[        [        SU R                  U-  5      5      nO[        U R                  5      n[        R                  " U[        S9n[        R                  " U[        S9n	U(       a  / U l        / U l        / U l        / U l        [        R$                  " U5      U:  Ga  [        R&                  " U5      U   n
[)        U R*                  5      nU R,                  S:  a"  [/        S[        R$                  " U5      -  5        UR0                  " US S 2U
4   U40 UD6  U(       a  U R                  R3                  [5        U
5      5        U R                  R3                  U" X5      5        U R                   R3                  [7        U5      5        U R"                  R3                  [7        U	5      5        [9        UU R:                  SS9n[        R<                  " U5      n[        R>                  " U5      n[A        U[        R$                  " U5      U-
  5      nSXU   S U '   U	[        RB                  " U5      ==   S-  ss'   [        R$                  " U5      U:  a  GM  [        R&                  " U5      U   n
[)        U R*                  5      U l"        U RD                  R0                  " US S 2U
4   U40 UD6  U(       a  U R                  R3                  [5        U
5      5        U R                  R3                  U" U RD                  U
5      5        U R                   R3                  U5        U R"                  R3                  U	5        UR%                  5       U l#        Xl$        Xl%        U $ )Ncscr   FTaccept_sparseensure_min_featuresensure_all_finitemulti_outputr$   zFound n_features_to_select= > n_features=C. There will be no feature selection and all features will be kept.g        g      ?)dtyper   z#Fitting estimator with %d features.square)transform_func)&r#   shaperN   
isinstancer   warningswarnUserWarningintrO   maxnponesboolr<   r9   r:   r;   sumaranger
   r-   rM   printr6   appendlenlistr&   rP   argsortravelminlogical_notr^   n_features_support_ranking_)rV   r*   r>   
step_scorerD   
n_featuresrN   rO   r   r   r.   r-   importancesranks	thresholds                  r2   r8   RFE._fit  si   
  !#
 WWQZ
$$,#-? 118<<#'#<#< #06!5 7:- HO O   $'z4M4M'M#N  S s1dii*456Dtyy>D77:T277:S1$&D! "D!#D!#D ffX!55yy,X6H dnn-I||a;bffX>NNOMM!AxK.!:z: %%,,S];!!((I)HI""))$x.9""))$x.9 3&&'K
 JJ{+E HHUOE D"&&"25I"IJI49He_Zi01R^^H-.!3.E ffX!55J 99Z(2/AakNA<< !!((X7$$Z%JK%%h/%%h/#<<>  r5   predictc                 
   [        X S5        [        U 5        [        5       (       a  [        U S40 UD6nO[	        [	        0 S9S9nU R
                  R                  " U R                  U5      40 UR                  R                  D6$ )aj  Reduce X to the selected features and predict using the estimator.

Parameters
----------
X : array of shape [n_samples, n_features]
    The input samples.

**predict_params : dict
    Parameters to route to the ``predict`` method of the
    underlying estimator.

    .. versionadded:: 1.6
        Only available if `enable_metadata_routing=True`,
        which can be set by using
        ``sklearn.set_config(enable_metadata_routing=True)``.
        See :ref:`Metadata Routing User Guide <metadata_routing>`
        for more details.

Returns
-------
y : array of shape [n_samples]
    The predicted target values.
r   )r   re   )	r   r"   r   r   r   r^   r   	transformr-   )rV   r*   predict_paramsrA   s       r2   r   RFE.predictz  sv    2 	.	:+D)N~NM!E",=>M&&NN1
!.!8!8!@!@
 	
r5   r7   c                     [        U 5        [        5       (       a  [        U S40 UD6nO[        [        US9S9nU R                  R
                  " U R                  U5      U40 UR                  R
                  D6$ )a$  Reduce X to the selected features and return the score of the estimator.

Parameters
----------
X : array of shape [n_samples, n_features]
    The input samples.

y : array of shape [n_samples]
    The target values.

**score_params : dict
    - If `enable_metadata_routing=False` (default): Parameters directly passed
      to the ``score`` method of the underlying estimator.

    - If `enable_metadata_routing=True`: Parameters safely routed to the `score`
      method of the underlying estimator.

    .. versionadded:: 1.0

    .. versionchanged:: 1.6
        See :ref:`Metadata Routing User Guide <metadata_routing>`
        for more details.

Returns
-------
score : float
    Score of the underlying base estimator computed with the selected
    features returned by `rfe.transform(X)` and `y`.
r7   r7   re   )r"   r   r   r   r^   r7   r   r-   )rV   r*   r>   r,   rA   s        r2   r7   	RFE.score  sn    > 	+D'J\JM!E,EFM$$NN1q
$1$;$;$A$A
 	
r5   c                 0    [        U 5        U R                  $ rT   )r"   r   r[   s    r2   _get_support_maskRFE._get_support_mask  s    }}r5   decision_functionc                 l    [        U 5        U R                  R                  U R                  U5      5      $ )a?  Compute the decision function of ``X``.

Parameters
----------
X : {array-like or 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
-------
score : array, shape = [n_samples, n_classes] or [n_samples]
    The decision function of the input samples. The order of the
    classes corresponds to that in the attribute :term:`classes_`.
    Regression and binary classification produce an array of shape
    [n_samples].
)r"   r^   r   r   rV   r*   s     r2   r   RFE.decision_function  s*    & 	001BCCr5   predict_probac                 l    [        U 5        U R                  R                  U R                  U5      5      $ )a  Predict class probabilities for X.

Parameters
----------
X : {array-like or 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
-------
p : array of shape (n_samples, n_classes)
    The class probabilities of the input samples. The order of the
    classes corresponds to that in the attribute :term:`classes_`.
)r"   r^   r   r   r   s     r2   r   RFE.predict_proba  s*    " 	,,T^^A->??r5   predict_log_probac                 l    [        U 5        U R                  R                  U R                  U5      5      $ )aE  Predict class log-probabilities for X.

Parameters
----------
X : array of shape [n_samples, n_features]
    The input samples.

Returns
-------
p : array of shape (n_samples, n_classes)
    The class log-probabilities of the input samples. The order of the
    classes corresponds to that in the attribute :term:`classes_`.
)r"   r^   r   r   r   s     r2   r   RFE.predict_log_proba  s*     	001BCCr5   c                   > [         TU ]  5       n[        U R                  5      nUR                  Ul        [        UR                  5      Ul        [        UR                  5      Ul        UR                  b  SUR                  l        UR                  b  SUR                  l        SUR                  l
        UR                  R                  UR                  l        UR                  R                  UR                  l        U$ )NT)super__sklearn_tags__r   r-   estimator_typer   classifier_tagsregressor_tags
poor_scoretarget_tagsrequired
input_tagssparse	allow_nan)rV   tagssub_estimator_tags	__class__s      r2   r   RFE.__sklearn_tags__  s    w')%dnn50??'(:(J(JK&'9'H'HI+.2D  +*-1D*$(!!3!>!>!E!E$6$A$A$K$K!r5   c                     [        U R                  R                  S9R                  U R                  [        5       R                  SSS9R                  SSS9R                  SSS9S9nU$ )"  Get metadata routing of this object.

Please check :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

.. versionadded:: 1.6

Returns
-------
routing : MetadataRouter
    A :class:`~sklearn.utils.metadata_routing.MetadataRouter` encapsulating
    routing information.
ownerr6   callercalleer   r7   r-   method_mapping)r   r   __name__addr-   r   rV   routers     r2   get_metadata_routingRFE.get_metadata_routing  sf      dnn&=&=>BBnn(?SeS,S	)S4SS0 C 
 r5   )r-   r^   rP   r   rN   r   rO   r<   r;   r9   r:   r   rM   rT   )!r   
__module____qualname____firstlineno____doc__r   r   r   r   strcallablerQ   dict__annotations__rW   propertyrZ   r_   r	   r6   r8   r   r!   r   r7   r   r   r   r   r   r   __static_attributes____classcell__)r   s   @r2   rG   rG   D   s   |~ !%)*ZAg6Xq$y9!
 Xq$y9ZAi8
 ;!8_$D & "   . . ( ( &+ >	 >DbH .+,!
 -!
F .)*&
 +&
P .!456D 7D* .12@ 3@& .!456D 7D" r5   rG   c                      \ rS rSr% Sr0 \R                  E\" \SSSS9/S/S\	\
/S\/S.Er\\S	'   \R                  S
5        S\R                  0rSSSSSSSS.S jr\" SS9\" SS9SS.S j5       5       rS rS rS rSrg)RFECVi.  a>  Recursive feature elimination with cross-validation to select features.

The number of features selected is tuned automatically by fitting an :class:`RFE`
selector on the different cross-validation splits (provided by the `cv` parameter).
The performance of each :class:`RFE` selector is evaluated using `scoring` for
different numbers of selected features and aggregated together. Finally, the scores
are averaged across folds and the number of features selected is set to the number
of features that maximize the cross-validation score.

See glossary entry for :term:`cross-validation estimator`.

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

Parameters
----------
estimator : ``Estimator`` instance
    A supervised learning estimator with a ``fit`` method that provides
    information about feature importance either through a ``coef_``
    attribute or through a ``feature_importances_`` attribute.

step : int or float, default=1
    If greater than or equal to 1, then ``step`` corresponds to the
    (integer) number of features to remove at each iteration.
    If within (0.0, 1.0), then ``step`` corresponds to the percentage
    (rounded down) of features to remove at each iteration.
    Note that the last iteration may remove fewer than ``step`` features in
    order to reach ``min_features_to_select``.

min_features_to_select : int, default=1
    The minimum number of features to be selected. This number of features
    will always be scored, even if the difference between the original
    feature count and ``min_features_to_select`` isn't divisible by
    ``step``.

    .. versionadded:: 0.20

cv : int, cross-validation generator or an iterable, default=None
    Determines the cross-validation splitting strategy.
    Possible inputs for cv are:

    - None, to use the default 5-fold cross-validation,
    - integer, to specify the number of folds.
    - :term:`CV splitter`,
    - An iterable yielding (train, test) splits as arrays of indices.

    For integer/None inputs, if ``y`` is binary or multiclass,
    :class:`~sklearn.model_selection.StratifiedKFold` is used. If the
    estimator is not a classifier or if ``y`` is neither binary nor multiclass,
    :class:`~sklearn.model_selection.KFold` is used.

    Refer :ref:`User Guide <cross_validation>` for the various
    cross-validation strategies that can be used here.

    .. versionchanged:: 0.22
        ``cv`` default value of None changed from 3-fold to 5-fold.

scoring : str or callable, default=None
    Scoring method to evaluate the :class:`RFE` selectors' performance. Options:

    - str: see :ref:`scoring_string_names` for options.
    - callable: a scorer callable object (e.g., function) with signature
      ``scorer(estimator, X, y)``. See :ref:`scoring_callable` for details.
    - `None`: the `estimator`'s
      :ref:`default evaluation criterion <scoring_api_overview>` is used.

verbose : int, default=0
    Controls verbosity of output.

n_jobs : int or None, default=None
    Number of cores to run in parallel while fitting across folds.
    ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
    ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
    for more details.

    .. versionadded:: 0.18

importance_getter : str or callable, default='auto'
    If 'auto', uses the feature importance either through a `coef_`
    or `feature_importances_` attributes of estimator.

    Also accepts a string that specifies an attribute name/path
    for extracting feature importance.
    For example, give `regressor_.coef_` in case of
    :class:`~sklearn.compose.TransformedTargetRegressor`  or
    `named_steps.clf.feature_importances_` in case of
    :class:`~sklearn.pipeline.Pipeline` with its last step named `clf`.

    If `callable`, overrides the default feature importance getter.
    The callable is passed with the fitted estimator and it should
    return importance for each feature.

    .. versionadded:: 0.24

Attributes
----------
classes_ : ndarray of shape (n_classes,)
    The classes labels. Only available when `estimator` is a classifier.

estimator_ : ``Estimator`` instance
    The fitted estimator used to select features.

cv_results_ : dict of ndarrays
    All arrays (values of the dictionary) are sorted in ascending order
    by the number of features used (i.e., the first element of the array
    represents the models that used the least number of features, while the
    last element represents the models that used all available features).

    .. versionadded:: 1.0

    This dictionary contains the following keys:

    split(k)_test_score : ndarray of shape (n_subsets_of_features,)
        The cross-validation scores across (k)th fold.

    mean_test_score : ndarray of shape (n_subsets_of_features,)
        Mean of scores over the folds.

    std_test_score : ndarray of shape (n_subsets_of_features,)
        Standard deviation of scores over the folds.

    n_features : ndarray of shape (n_subsets_of_features,)
        Number of features used at each step.

        .. versionadded:: 1.5

    split(k)_ranking : ndarray of shape (n_subsets_of_features,)
        The cross-validation rankings across (k)th fold.
        Selected (i.e., estimated best) features are assigned rank 1.
        Illustration in
        :ref:`sphx_glr_auto_examples_feature_selection_plot_rfe_with_cross_validation.py`

        .. versionadded:: 1.7

    split(k)_support : ndarray of shape (n_subsets_of_features,)
        The cross-validation supports across (k)th fold. The support
        is the mask of selected features.

        .. versionadded:: 1.7

n_features_ : int
    The number of selected features with cross-validation.

n_features_in_ : int
    Number of features seen during :term:`fit`. Only defined if the
    underlying estimator exposes such an attribute when 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

ranking_ : narray of shape (n_features,)
    The feature ranking, such that `ranking_[i]`
    corresponds to the ranking
    position of the i-th feature.
    Selected (i.e., estimated best)
    features are assigned rank 1.

support_ : ndarray of shape (n_features,)
    The mask of selected features.

See Also
--------
RFE : Recursive feature elimination.

Notes
-----
The size of all values in ``cv_results_`` is equal to
``ceil((n_features - min_features_to_select) / step) + 1``,
where step is the number of features removed at each iteration.

Allows NaN/Inf in the input if the underlying estimator does as well.

References
----------

.. [1] Guyon, I., Weston, J., Barnhill, S., & Vapnik, V., "Gene selection
       for cancer classification using support vector machines",
       Mach. Learn., 46(1-3), 389--422, 2002.

Examples
--------
The following example shows how to retrieve the a-priori not known 5
informative features in the Friedman #1 dataset.

>>> from sklearn.datasets import make_friedman1
>>> from sklearn.feature_selection import RFECV
>>> from sklearn.svm import SVR
>>> X, y = make_friedman1(n_samples=50, n_features=10, random_state=0)
>>> estimator = SVR(kernel="linear")
>>> selector = RFECV(estimator, step=1, cv=5)
>>> selector = selector.fit(X, y)
>>> selector.support_
array([ True,  True,  True,  True,  True, False, False, False, False,
       False])
>>> selector.ranking_
array([1, 1, 1, 1, 1, 6, 4, 3, 2, 5])

For a detailed example of using RFECV to select features when training a
:class:`~sklearn.linear_model.LogisticRegression`, see
:ref:`sphx_glr_auto_examples_feature_selection_plot_rfe_with_cross_validation.py`.
r   NrL   rJ   	cv_object)min_features_to_selectcvscoringn_jobsrQ   rN   groupsr$   rR   )rO   r   r   r   rM   r   rP   c                d    Xl         X l        Xl        X@l        XPl        X`l        Xpl        X0l        g rT   )r-   rO   rP   r   r   rM   r   r   )	rV   r-   rO   r   r   r   rM   r   rP   s	            r2   rW   RFECV.__init__  s.     #	!2&<#r5   z1.8)versionFra   )r   c          
        ^ ^^^^^^ [        UT S5        [        T TTSSSSS9u  mm[        5       (       a$  Ub  UR                  SU05        [	        T S40 UD6mO"[        [        0 S	9[        SU0S
9[        0 S9S9m[        T R                  T[        T R                  5      S9nT R                  5       mTR                  S   nT R                  U:  a-  [        R                  " ST R                   SU< S3[        5        [!        T R                  [#        T R                  U5      T R$                  T R&                  T R(                  S9m[+        T R,                  5      S:X  a  [.        [0        snmO"[3        T R,                  S9n[5        [0        5      mU" UUUUUU U4S jUR6                  " TT40 TR8                  R6                  D6 5       5      n[;        U6 u  pp[<        R>                  " US   5      SSS2   n[<        R>                  " U	5      n	[<        R>                  " U5      n[<        R>                  " U
5      n
[<        R@                  " U	SS9SSS2   nU[<        RB                  " U5         n[!        T R                  UT R&                  T R$                  T R(                  S9mTRD                  " TT40 TR                  RD                  D6  TRF                  T l#        TRH                  T l$        TRJ                  T l%        [M        T R                  5      T l'        T RN                  RD                  " T RQ                  T5      T40 TR                  RD                  D6  U	SS2SSS24   nU
SS2SSS24   nUSS2SSS24   n[<        RR                  " USS9[<        RT                  " USS9S.[W        U	R                  S   5       Vs0 s H  nSU S3UU   _M     snE[W        UR                  S   5       Vs0 s H  nSU S3UU   _M     snE[W        U
R                  S   5       Vs0 s H  nSU S3UU   _M     snESU0ET l,        T $ s  snf s  snf s  snf )a  Fit the RFE model and automatically tune the number of selected features.

Parameters
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features)
    Training vector, where `n_samples` is the number of samples and
    `n_features` is the total number of features.

y : array-like of shape (n_samples,)
    Target values (integers for classification, real numbers for
    regression).

groups : array-like of shape (n_samples,) or None, default=None
    Group labels for the samples used while splitting the dataset into
    train/test set. Only used in conjunction with a "Group" :term:`cv`
    instance (e.g., :class:`~sklearn.model_selection.GroupKFold`).

    .. versionadded:: 0.20

**params : dict of str -> object
    Parameters passed to the ``fit`` method of the estimator,
    the scorer, and the CV splitter.

    .. versionadded:: 1.6
        Only available if `enable_metadata_routing=True`,
        which can be set by using
        ``sklearn.set_config(enable_metadata_routing=True)``.
        See :ref:`Metadata Routing User Guide <metadata_routing>`
        for more details.

Returns
-------
self : object
    Fitted estimator.
r6   csrr   FTri   Nr   rd   )splitr   )r-   splitterr0   )
classifierr$   zFound min_features_to_select=rn   ro   )r-   rN   rP   rO   rM   )r   c              3   j   >#    U  H(  u  pT" [        T5      TR                  TT	XTT5      v   M*     g 7frT   )r
   r-   )
.0r?   r@   r*   funcr=   rA   r0   rV   r>   s
      r2   	<genexpr>RFECV.fit.<locals>.<genexpr>  s6       
M sT^^Q5VVMs   03r   )axisrU   )mean_test_scorestd_test_scorer   _test_score_ranking_supportr   )-r   r#   r   updater   r   r   r   r   r-   _get_scorerrs   r   ru   rv   rw   rG   r   rP   rO   rM   r   r   r   rE   r   r   r   r   ziprz   arrayr}   argmaxr6   r   r   r   r
   r^   
_transformmeanstdrangecv_results_)rV   r*   r>   r   r(   r   r   parallelstep_resultsscoressupportsrankingsstep_n_featuresstep_n_features_revscores_sum_revrN   
scores_revsupports_revrankings_revir   r=   rA   r0   s   ```                 @@@@r2   r6   	RFECV.fit  s   R 	&$. !#
1 !x01+D%B6BM!B-h%782M dggq]4>>-JK!!# WWQZ
&&3MM3D4O4O3P Q#!m $--  nn!$T%@%@*!M"44LL
( DKK(A-!?NHdt{{3H?+D  
  
!xx1M0F0F0L0LM 
 
 7:<6H3( hhq'9:4R4@&!88H%88H% Q/"52299^3LM nn!5"44LL
 	14//334 ??/DOOA.Q]5L5L5P5PQ AttG_
4R4(4R4(!wwz: ffZa8
 ?DFLLQRO>TU>Tqc%z!}4>TU
 >C8>>RSCT=UV=Uqc"LO3=UV	

 >C8>>RSCT=UV=Uqc"LO3=UV
 -
  VVVs   Q4Q%Qc                     [        X0S5        U R                  5       n[        5       (       a  [        U S40 UD6nO[	        5       n[	        0 S9Ul        U" XU40 UR
                  R                  D6$ )a  Score using the `scoring` option on the given test data and labels.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Test samples.

y : array-like of shape (n_samples,)
    True labels for X.

**score_params : dict
    Parameters to pass to the `score` method of the underlying scorer.

    .. versionadded:: 1.6
        Only available if `enable_metadata_routing=True`,
        which can be set by using
        ``sklearn.set_config(enable_metadata_routing=True)``.
        See :ref:`Metadata Routing User Guide <metadata_routing>`
        for more details.

Returns
-------
score : float
    Score of self.predict(X) w.r.t. y defined by `scoring`.
r7   r   )r   r   r   r   r   r0   r7   )rV   r*   r>   r,   r   rA   s         r2   r7   RFECV.score  sg    4 	,g6""$+D'J\JM!GM#(r?M t@]%9%9%?%?@@r5   c                    [        U R                  R                  S9nUR                  U R                  [        5       R                  SSS9S9  UR                  [        U R                  5      [        5       R                  SSS9S9  UR                  U R                  5       [        5       R                  SSS9R                  SSS9S9  U$ )	r   r   r6   r   r   r   )r   r   r7   )r0   r   )	r   r   r   r   r-   r   r   r   r   r   s     r2   r   RFECV.get_metadata_routing  s      dnn&=&=>

nn(?..eE.J 	 	
 	

dgg&(?.. /  	 	
 	

##%(?SgS.SS0	 	 	
 r5   c                     U R                   c  [        U R                  5      (       a  SOSnOU R                   n[        U5      $ )Naccuracyr2)r   r   r-   r   )rV   r   s     r2   r   RFECV._get_scorer  s5    <<$1$..$A$AjtGllG'""r5   )r   r   r-   r^   rP   r   r   r   r   r   rO   r   rM   )r   r   r   r   r   rG   rQ   r   r   r   r   r   r   popr   UNUSED_RFECV__metadata_request__fitrW   r    r	   r6   r7   r   r   r    r5   r2   r   r   .  s    L\$

$
$$#+Hai#P"Qm#x("$D  56')9)@)@A   =,  .&+ #' Q	 /
Qf"AH!F#r5   r   )7r   ru   copyr   numbersr   numpyrz   joblibr   baser   r   r	   r
   r   metricsr   model_selectionr   model_selection._validationr   utilsr   r   utils._metadata_requestsr   r   r   r   r   utils._param_validationr   r   r   utils._tagsr   utils.metaestimatorsr   r   utils.parallelr   r   utils.validationr   r    r!   r"   r#   _baser%   r&   rE   rG   r   r  r5   r2   <module>r     s~    8     # X X   & 0 +  G F " < .  ;X:g-+] gTS#C S#r5   