ó
    §ñ:iR(  ã                   óÜ   • S r SSKJr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Jr  SS	KJr  SS
KJr  SSKJr  SSKJr   SS jrSS jr " S S\\\S9rS r " S S\\\S9rg)z)Base class for ensemble-based estimators.é    )ÚABCMetaÚabstractmethod)ÚListN)Úeffective_n_jobsé   )ÚBaseEstimatorÚMetaEstimatorMixinÚcloneÚis_classifierÚis_regressor)ÚBunchÚcheck_random_state©Ú
_safe_tags)Ú_print_elapsed_time)Ú_routing_enabled)Ú_BaseCompositionc                 ó¼  • [        5       (       d0  SU;   a*   [        XE5         U R                  XUS   S9  SSS5        U $ [        XE5         U R                  " X40 UD6  SSS5        U $ ! , (       d  f       U $ = f! [         aD  nS[	        U5      ;   a/  [        SR                  U R                  R                  5      5      Uee SnAff = f! , (       d  f       U $ = f)z7Private function used to fit an estimator within a job.Úsample_weight)r   Nz+unexpected keyword argument 'sample_weight'z8Underlying estimator {} does not support sample weights.)r   r   ÚfitÚ	TypeErrorÚstrÚformatÚ	__class__Ú__name__)Ú	estimatorÚXÚyÚ
fit_paramsÚmessage_clsnameÚmessageÚexcs          ÚY/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/sklearn/ensemble/_base.pyÚ_fit_single_estimatorr$      sÚ   € ô ×Ñ /°ZÓ"?ð
	Ü$ _Õ>Ø—‘˜a°*¸_Ñ2M�ÑN÷ ?ð Ðô ! Õ:Ø�MŠM˜!Ñ- *Ò-÷ ;àÐ÷ ?Ô>ð Ðûô ó 	Ø<ÄÀCÃÓHÜØN×UÑUØ!×+Ñ+×4Ñ4óóð ð	ð
 ûð	ú÷ ;Ô:àÐús?   —A; ¢A)¶A; ÁCÁ)
A8Á3A; Á8A; Á;
C	Â?CÃC	Ã
Cc                 óJ  • [        U5      n0 n[        U R                  SS95       H`  nUS:X  d  UR                  S5      (       d  M!  UR	                  [
        R                  " [
        R                  5      R                  5      X#'   Mb     U(       a  U R                  " S0 UD6  gg)ae  Set fixed random_state parameters for an estimator.

Finds all parameters ending ``random_state`` and sets them to integers
derived from ``random_state``.

Parameters
----------
estimator : estimator supporting get/set_params
    Estimator with potential randomness managed by random_state
    parameters.

random_state : int, RandomState instance or None, default=None
    Pseudo-random number generator to control the generation of the random
    integers. Pass an int for reproducible output across multiple function
    calls.
    See :term:`Glossary <random_state>`.

Notes
-----
This does not necessarily set *all* ``random_state`` attributes that
control an estimator's randomness, only those accessible through
``estimator.get_params()``.  ``random_state``s not controlled include
those belonging to:

    * cross-validation splitters
    * ``scipy.stats`` rvs
T©ÚdeepÚrandom_stateÚ__random_stateN© )
r   ÚsortedÚ
get_paramsÚendswithÚrandintÚnpÚiinfoÚint32ÚmaxÚ
set_params)r   r(   Úto_setÚkeys       r#   Ú_set_random_statesr6   ,   s‡   € ô8 & lÓ3€LØ€FÜ�i×*Ñ*°Ð*Ð5Ö6ˆØ�.Ó  C§L¡LÐ1A×$BÓ$BØ&×.Ñ.¬r¯xªx¼¿¹Ó/A×/EÑ/EÓFˆF‹Kñ 7ö Ø×ÒÑ&˜vÓ&ð ó    c                   ó~   • \ rS rSr% Sr/ r\\   \S'   \	 SS\
" 5       S.S jj5       rSS jrSS	 jrS
 rS rS rSrg)ÚBaseEnsembleéR   aš  Base class for all ensemble classes.

Warning: This class should not be used directly. Use derived classes
instead.

Parameters
----------
estimator : object
    The base estimator from which the ensemble is built.

n_estimators : int, default=10
    The number of estimators in the ensemble.

estimator_params : list of str, default=tuple()
    The list of attributes to use as parameters when instantiating a
    new base estimator. If none are given, default parameters are used.

Attributes
----------
estimator_ : estimator
    The base estimator from which the ensemble is grown.

estimators_ : list of estimators
    The collection of fitted base estimators.
Ú_required_parametersNé
   )Ún_estimatorsÚestimator_paramsc                ó(   • Xl         X l        X0l        g ©N)r   r=   r>   )Úselfr   r=   r>   s       r#   Ú__init__ÚBaseEnsemble.__init__p   s   € ð #ŒØ(ÔØ 0Õr7   c                 óN   • U R                   b  U R                   U l        gXl        g)z=Check the base estimator.

Sets the `estimator_` attributes.
N)r   Ú
estimator_)rA   Údefaults     r#   Ú_validate_estimatorÚ BaseEnsemble._validate_estimator�   s   € ð
 �>‰>Ñ%Ø"Ÿn™nˆD�Oà%�Or7   c                 ó  • [        U R                  5      nUR                  " S0 U R                   Vs0 s H  oD[	        X5      _M     snD6  Ub  [        X25        U(       a  U R                  R                  U5        U$ s  snf )zŠMake and configure a copy of the `estimator_` attribute.

Warning: This method should be used to properly instantiate new
sub-estimators.
r*   )r
   rE   r3   r>   Úgetattrr6   Úestimators_Úappend)rA   rL   r(   r   Úps        r#   Ú_make_estimatorÚBaseEnsemble._make_estimator‹   ss   € ô ˜$Ÿ/™/Ó*ˆ	Ø×ÒÑT¸T×=RÒ=RÓSÒ=R¸¤7¨4Ó#3Ò 3Ñ=RÑSÒTàÑ#Ü˜yÔ7æØ×Ñ×#Ñ# IÔ.àÐùò  Ts   ²A>c                 ó,   • [        U R                  5      $ )z0Return the number of estimators in the ensemble.)ÚlenrK   ©rA   s    r#   Ú__len__ÚBaseEnsemble.__len__œ   s   € ä�4×#Ñ#Ó$Ð$r7   c                 ó    • U R                   U   $ )z.Return the index'th estimator in the ensemble.)rK   )rA   Úindexs     r#   Ú__getitem__ÚBaseEnsemble.__getitem__    s   € à×Ñ Ñ&Ð&r7   c                 ó,   • [        U R                  5      $ )z0Return iterator over estimators in the ensemble.)ÚiterrK   rR   s    r#   Ú__iter__ÚBaseEnsemble.__iter__¤   s   € ä�D×$Ñ$Ó%Ð%r7   )r   rE   r>   r=   r@   )TN)r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r;   r   r   Ú__annotations__r   ÚtuplerB   rG   rN   rS   rW   r[   Ú__static_attributes__r*   r7   r#   r9   r9   R   sW   ‡ ñð6 ')Ð˜$˜s™)Ó(àð ð
1ð Ù›õ
1ó ð
1ô &ôò"%ò'õ&r7   r9   )Ú	metaclassc                 óø   • [        [        U5      U 5      n[        R                  " XU-  [        S9nUSX-  === S-  sss& [        R
                  " U5      nXR                  5       S/UR                  5       -   4$ )z;Private function used to partition estimators between jobs.)ÚdtypeNé   r   )Úminr   r/   ÚfullÚintÚcumsumÚtolist)r=   Ún_jobsÚn_estimators_per_jobÚstartss       r#   Ú_partition_estimatorsrp   ©   st   € ô Ô! &Ó)¨<Ó8€Fô Ÿ7š7 6¸6Ñ+AÌÑMÐØÐ0˜<Ñ0Ó1°QÑ6Ó1Ü�YŠYÐ+Ó,€Fà×.Ñ.Ó0°1°#¸¿¹»Ñ2GÐGÐGr7   c                   ón   ^ • \ rS rSrSrS/r\S 5       r\S 5       r	S r
U 4S jrSU 4S jjrS	 rS
rU =r$ )Ú_BaseHeterogeneousEnsembleé¶   aI  Base class for heterogeneous ensemble of learners.

Parameters
----------
estimators : list of (str, estimator) tuples
    The ensemble of estimators to use in the ensemble. Each element of the
    list is defined as a tuple of string (i.e. name of the estimator) and
    an estimator instance. An estimator can be set to `'drop'` using
    `set_params`.

Attributes
----------
estimators_ : list of estimators
    The elements of the estimators parameter, having been fitted on the
    training data. If an estimator has been set to `'drop'`, it will not
    appear in `estimators_`.
Ú
estimatorsc                 ó>   • [        S0 [        U R                  5      D6$ )zgDictionary to access any fitted sub-estimators by name.

Returns
-------
:class:`~sklearn.utils.Bunch`
r*   )r   Údictrt   rR   s    r#   Únamed_estimatorsÚ+_BaseHeterogeneousEnsemble.named_estimatorsÍ   s   € ô Ñ-”t˜DŸO™OÓ,Ñ-Ð-r7   c                 ó   • Xl         g r@   ©rt   )rA   rt   s     r#   rB   Ú#_BaseHeterogeneousEnsemble.__init__×   s   € à$�r7   c           	      óÎ  • [        U R                  5      S:X  a  [        S5      e[        U R                  6 u  pU R	                  U5        [        S U 5       5      nU(       d  [        S5      e[        U 5      (       a  [        O[        nU HT  nUS:w  d  M  U" U5      (       a  M  [        SR                  UR                  R                  UR                  SS  5      5      e   X4$ )Nr   zfInvalid 'estimators' attribute, 'estimators' should be a non-empty list of (string, estimator) tuples.c              3   ó*   #   • U  H	  oS :g  v •  M     g7f)ÚdropNr*   ©Ú.0Úests     r#   Ú	<genexpr>ÚB_BaseHeterogeneousEnsemble._validate_estimators.<locals>.<genexpr>å   s   é € Ð@²Z¨c 6žM²Zùs   ‚zHAll estimators are dropped. At least one is required to be an estimator.r~   z The estimator {} should be a {}.é   )rQ   rt   Ú
ValueErrorÚzipÚ_validate_namesÚanyr   r   r   r   r   )rA   Únamesrt   Úhas_estimatorÚis_estimator_typer�   s         r#   Ú_validate_estimatorsÚ/_BaseHeterogeneousEnsemble._validate_estimatorsÛ   sß   € Üˆt�‰Ó 1Ó$Üð@óð ô   §¡Ð1Ñˆà×Ñ˜UÔ#äÑ@±ZÓ@Ó@ˆÞÜð&óð ô
 .;¸4×-@Ñ-@�MÄlÐãˆCØ�f�}Ñ%6°s×%;Ó%;Ü Ø6×=Ñ=ØŸ™×.Ñ.Ð0A×0JÑ0JÈ1È2Ð0Nóóð ñ ð Ð Ð r7   c                 ó(   >• [         TU ]  " S0 UD6  U $ )a3  
Set the parameters of an estimator from the ensemble.

Valid parameter keys can be listed with `get_params()`. Note that you
can directly set the parameters of the estimators contained in
`estimators`.

Parameters
----------
**params : keyword arguments
    Specific parameters using e.g.
    `set_params(parameter_name=new_value)`. In addition, to setting the
    parameters of the estimator, the individual estimator of the
    estimators can also be set, or can be removed by setting them to
    'drop'.

Returns
-------
self : object
    Estimator instance.
rz   )ÚsuperÚ_set_params)rA   Úparamsr   s     €r#   r3   Ú%_BaseHeterogeneousEnsemble.set_paramsø   s   ø€ ô, 	‰ÒÑ3¨FÒ3Øˆr7   c                 ó    >• [         TU ]  SUS9$ )aÌ  
Get the parameters of an estimator from the ensemble.

Returns the parameters given in the constructor as well as the
estimators contained within the `estimators` parameter.

Parameters
----------
deep : bool, default=True
    Setting it to True gets the various estimators and the parameters
    of the estimators as well.

Returns
-------
params : dict
    Parameter and estimator names mapped to their values or parameter
    names mapped to their values.
rt   r&   )r�   Ú_get_params)rA   r'   r   s     €r#   r,   Ú%_BaseHeterogeneousEnsemble.get_params  s   ø€ ô& ‰wÑ" <°dÐ"Ð;Ð;r7   c                 ój   •  [        S U R                   5       5      n/ US.$ ! [         a    Sn Nf = f)Nc              3   óZ   #   • U  H!  nUS    S:w  a  [        US    5      S   OSv •  M#     g7f)rg   r~   Ú	allow_nanTNr   r   s     r#   r‚   Ú8_BaseHeterogeneousEnsemble._more_tags.<locals>.<genexpr>(  s5   é € ð â*�Cð 47°q±6¸VÓ3C”
˜3˜q™6Ó" ;Ò/ÈÔMÚ*ùs   ‚)+F)Úpreserves_dtyper˜   )Úallrt   Ú	Exception)rA   r˜   s     r#   Ú
_more_tagsÚ%_BaseHeterogeneousEnsemble._more_tags&  sG   € ð		Üñ àŸ?š?óó ˆIð $&°IÑ>Ð>øô ó 	ð ŠIð		ús   ‚# £2±2rz   )T)r   r]   r^   r_   r`   r;   Úpropertyrw   r   rB   rŒ   r3   r,   r�   rc   Ú__classcell__)r   s   @r#   rr   rr   ¶   sQ   ø† ñð$ )˜>Ðàñ.ó ð.ð ñ%ó ð%ò!õ:÷2<÷*?ð ?r7   rr   )NNr@   ) r`   Úabcr   r   Útypingr   Únumpyr/   Újoblibr   Úbaser   r	   r
   r   r   Úutilsr   r   Úutils._tagsr   Úutils._user_interfacer   Úutils.metadata_routingr   Úutils.metaestimatorsr   r$   r6   r9   rp   rr   r*   r7   r#   Ú<module>r«      sk   ðÙ /÷
 (Ý ã Ý #ç XÕ Xß -Ý $Ý 7Ý 5Ý 3ð @Dôô0#'ôLT&Ð% }Àò T&òn
Hô{?ØÐ(°Gó{?r7   