Ë
    ÜÍ:j‡	  ã                   óN   — d Z ddlZddlmZ ddlmZ ddlmZm	Z	  G d„ de«      Z
y)zY
Feature agglomeration. Base classes and functions for performing feature
agglomeration.
é    N)Úissparse)ÚTransformerMixin)Úcheck_is_fittedÚvalidate_datac                   ó   — e Zd ZdZd„ Zd„ Zy)ÚAgglomerationTransformzH
    A class for feature agglomeration via the transform interface.
    c                 ó„  — t        | «       t        | |d¬«      }| j                  t        j                  k(  r�t        |«      s„t        j                  | j                  «      }|j                  d   }t        j                  t        |«      D �cg c],  }t        j                  | j                  ||dd…f   «      |z  ‘Œ. c}«      }|S t        j                  | j                  «      D �cg c])  }| j                  |dd…| j                  |k(  f   d¬«      ‘Œ+ }}t        j                  |«      j                  }|S c c}w c c}w )aí  
        Transform a new matrix using the built clustering.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features) or                 (n_samples, n_samples)
            An M by N array of M observations in N dimensions or a length
            M array of M one-dimensional observations.

        Returns
        -------
        Y : ndarray of shape (n_samples, n_clusters) or (n_clusters,)
            The pooled values for each feature cluster.
        F)Úresetr   Né   )Úaxis)r   r   Úpooling_funcÚnpÚmeanr   ÚbincountÚlabels_ÚshapeÚarrayÚrangeÚuniqueÚT)ÚselfÚXÚsizeÚ	n_samplesÚiÚnXÚls          ú{/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/sklearn/cluster/_feature_agglomeration.pyÚ	transformz AgglomerationTransform.transform   s  € ô  	˜Ôä˜$ ¨Ô/ˆØ×Ñ¤§¡Ò'´¸´Ü—;‘;˜tŸ|™|Ó,ˆDØŸ™ ™
ˆIä—‘ÜDIÈ)ÓDTÖU¸q”—‘˜TŸ\™\¨1¨Q²¨T©7Ó3°dÓ:ÒUóˆBð ˆ	ô Ÿ™ 4§<¡<Ó0öàð ×!Ñ! !¢A t§|¡|°qÑ'8Ð$8Ñ"9ÀÐ!ÕBðˆBð ô —‘˜"“—‘ˆBØˆ	ùò Vùòs   Â1D8Ã'.D=c                 ón   — t        | «       t        j                  | j                  d¬«      \  }}|d|f   S )að  
        Inverse the transformation and return a vector of size `n_features`.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_clusters) or (n_clusters,)
            The values to be assigned to each cluster of samples.

        Returns
        -------
        X_original : ndarray of shape (n_samples, n_features) or (n_features,)
            A vector of size `n_samples` with the values of `X` assigned to
            each of the cluster of samples.
        T)Úreturn_inverse.)r   r   r   r   )r   r   ÚunilÚinverses       r   Úinverse_transformz(AgglomerationTransform.inverse_transform:   s2   € ô 	˜ÔäŸ	™	 $§,¡,¸tÔD‰ˆˆgØ��g�‰Ðó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r$   © r%   r   r   r      s   „ ñò óDr%   r   )r)   Únumpyr   Úscipy.sparser   Úsklearn.baser   Úsklearn.utils.validationr   r   r   r*   r%   r   ú<module>r/      s%   ðñó Ý !å )ß Cô9Ð-õ 9r%   