ó
    §ñ:i³  ã                   ó�   • S r SSKJrJr  SSKJr  SSKJrJr  SSK	r
SSKJr  SSKJr  SS	KJr  S
SKJr  S/r " S S\\S9rSS jrg)zUtilities for meta-estimators.é    )ÚABCMetaÚabstractmethod)Úsuppress)ÚAnyÚListNé   )ÚBaseEstimator)Ú_safe_indexing)Ú
_safe_tagsé   )Úavailable_ifr   c                   ój   ^ • \ rS rSr% Sr\\   \S'   \S 5       r	S
U 4S jjr
U 4S jrS rS rS	rU =r$ )Ú_BaseCompositioné   zJHandles parameter management for classifiers composed of named estimators.Ústepsc                 ó   • g ©N© )Úselfs    Ú_/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/sklearn/utils/metaestimators.pyÚ__init__Ú_BaseComposition.__init__   s   € àó    c                 ó<  >• [         T	U ]  US9nU(       d  U$ [        X5      n UR                  U5        U HI  u  pV[        US5      (       d  M  UR                  SS9R                  5        H  u  pxXƒU< SU< 3'   M     MK     U$ ! [        [
        4 a    Us $ f = f)N©ÚdeepÚ
get_paramsTÚ__)Úsuperr   ÚgetattrÚupdateÚ	TypeErrorÚ
ValueErrorÚhasattrÚitems)
r   Úattrr   ÚoutÚ
estimatorsÚnameÚ	estimatorÚkeyÚvalueÚ	__class__s
            €r   Ú_get_paramsÚ_BaseComposition._get_params   s¨   ø€ Ü‰gÑ  dÐ Ð+ˆÞØˆJä˜TÓ(ˆ
ð	Ø�J‰J�zÔ"ó  *‰OˆDÜ�y ,×/Ó/Ø"+×"6Ñ"6¸DÐ"6Ð"A×"GÑ"GÖ"I‘J�CØ27£Dª#Ð.Ó/ó #Jñ  *ð ˆ
øô œ:Ð&ó 	ð ŠJð	ús   ¤B ÂBÂBc           	      ó¼  >• X;   a  [        XUR                  U5      5        [        X5      n[        U[        5      (       ay  U(       ar  [        [        5         [        U6 u  pE[	        UR                  5       5       H3  nSU;  d  M  Xd;   d  M  U R                  XUR                  U5      5        M5     S S S 5        [        TU ],  " S0 UD6  U $ ! , (       d  f       N = f)Nr   r   )ÚsetattrÚpopr    Ú
isinstanceÚlistr   r"   ÚzipÚkeysÚ_replace_estimatorr   Ú
set_params)r   r&   Úparamsr%   Ú
item_namesÚ_r)   r-   s          €r   Ú_set_paramsÚ_BaseComposition._set_params3   s«   ø€ ð ‹>Ü�D §
¡
¨4Ó 0Ô1ä˜Ó#ˆÜ�eœT×"Ñ"¦uô œ)Õ$Ü # U ‘�
Ü  §¡£Ö/�DØ 4Õ'¨DÕ,>Ø×/Ñ/°¸F¿J¹JÀtÓ<LÖMñ 0÷ %ô 	‰ÒÑ$˜VÒ$Øˆ÷ %Õ$ús   Á+CÂCÂ%CÃ
Cc                 óŠ   • [        [        X5      5      n[        U5       H  u  nu  pgXb:X  d  M  X#4XE'     O   [        XU5        g r   )r4   r    Ú	enumerater1   )r   r&   r)   Únew_valÚnew_estimatorsÚiÚestimator_namer;   s           r   r7   Ú#_BaseComposition._replace_estimatorH   sH   € äœg dÓ1Ó2ˆÜ&/°Ö&?Ñ"ˆAÑ"�ØÕ%Ø%) O�Ñ!Ùñ '@ô 	�˜NÕ+r   c                 ó®  • [        [        U5      5      [        U5      :w  a#  [        SR                  [	        U5      5      5      e[        U5      R                  U R                  SS95      nU(       a#  [        SR                  [        U5      5      5      eU Vs/ s H  nSU;   d  M  UPM     nnU(       a  [        SR                  U5      5      eg s  snf )Nz$Names provided are not unique: {0!r}Fr   z:Estimator names conflict with constructor arguments: {0!r}r   z.Estimator names must not contain __: got {0!r})ÚlenÚsetr#   Úformatr4   Úintersectionr   Úsorted)r   ÚnamesÚinvalid_namesr)   s       r   Ú_validate_namesÚ _BaseComposition._validate_namesQ   s¼   € ÜŒs�5‹z‹?œc %›jÓ(ÜÐC×JÑJÌ4ÐPUË;ÓWÓXÐXÜ˜E›
×/Ñ/°·±ÀU°Ð0KÓLˆÞÜØL×SÑSÜ˜=Ó)óóð ñ
 +0Ó@ª% $°4¸4±<Ÿ©%ˆÐ@ÞÜØ@×GÑGÈÓVóð ð ùò As   Â
CÂ(Cr   )T)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   Ú__annotations__r   r   r.   r<   r7   rM   Ú__static_attributes__Ú__classcell__)r-   s   @r   r   r      s;   ø‡ ÙTà�‰9Óàñó ð÷õ,ò*,÷ð r   r   )Ú	metaclassc                 ó^  • [        U SS9(       a~  [        US5      (       d  [        S5      eUR                  S   UR                  S   :w  a  [        S5      eUc  U[        R
                  " X35         nO%U[        R
                  " X45         nO[        X5      nUb  [        X#5      nXV4$ SnXV4$ )	aa  Create subset of dataset and properly handle kernels.

Slice X, y according to indices for cross-validation, but take care of
precomputed kernel-matrices or pairwise affinities / distances.

If ``estimator._pairwise is True``, X needs to be square and
we slice rows and columns. If ``train_indices`` is not None,
we slice rows using ``indices`` (assumed the test set) and columns
using ``train_indices``, indicating the training set.

Labels y will always be indexed only along the first axis.

Parameters
----------
estimator : object
    Estimator to determine whether we should slice only rows or rows and
    columns.

X : array-like, sparse matrix or iterable
    Data to be indexed. If ``estimator._pairwise is True``,
    this needs to be a square array-like or sparse matrix.

y : array-like, sparse matrix or iterable
    Targets to be indexed.

indices : array of int
    Rows to select from X and y.
    If ``estimator._pairwise is True`` and ``train_indices is None``
    then ``indices`` will also be used to slice columns.

train_indices : array of int or None, default=None
    If ``estimator._pairwise is True`` and ``train_indices is not None``,
    then ``train_indices`` will be use to slice the columns of X.

Returns
-------
X_subset : array-like, sparse matrix or list
    Indexed data.

y_subset : array-like, sparse matrix or list
    Indexed targets.

Úpairwise)r+   ÚshapezXPrecomputed kernels or affinity matrices have to be passed as arrays or sparse matrices.r   r   z"X should be a square kernel matrixN)r   r$   r#   rZ   ÚnpÚix_r
   )r*   ÚXÚyÚindicesÚtrain_indicesÚX_subsetÚy_subsets          r   Ú_safe_splitrc   b   s´   € ôX �) ×,Ü�q˜'×"Ñ"Üð=óð ð
 �7‰7�1‰:˜Ÿ™ ™Ó#ÜÐAÓBÐBØÑ ØœŸš Ó1Ñ2‰HàœŸš Ó7Ñ8‰Hä! !Ó-ˆà�}Ü! !Ó-ˆð ÐÐð ˆàÐÐr   r   )rS   Úabcr   r   Ú
contextlibr   Útypingr   r   Únumpyr[   Úbaser	   Úutilsr
   Úutils._tagsr   Ú_available_ifr   Ú__all__r   rc   r   r   r   Ú<module>rm      sA   ðÙ $÷
 (Ý ß ã å  Ý "Ý $Ý 'àÐ
€ôK�}°ò Kõ\Ar   