
    Ki	                     N    S r SSKrSSKJr  SSKJr  SSKJrJ	r	   " S S\5      r
g)zY
Feature agglomeration. Base classes and functions for performing feature
agglomeration.
    N)issparse)TransformerMixin)check_is_fittedvalidate_datac                   $    \ rS rSrSrS rS rSrg)AgglomerationTransform   z@
A class for feature agglomeration via the transform interface.
c                    [        U 5        [        XSS9nU R                  [        R                  :X  a  [        U5      (       d  [        R                  " U R                  5      nUR                  S   n[        R                  " [        U5       Vs/ s H-  n[        R                  " U R                  XSS24   5      U-  PM/     sn5      nU$ [        R                  " U R                  5       Vs/ s H'  nU R                  USS2U R                  U:H  4   SS9PM)     nn[        R                  " U5      R                  nU$ s  snf s  snf )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          h/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/sklearn/cluster/_feature_agglomeration.py	transform AgglomerationTransform.transform   s     	$/';;t||,D
IDI)DTUDTqT\\1T73d:DTUB 	 4<<00A !!!At||q'8$8"9!B0   "B	 Vs   4E/.Ec                 h    [        U 5        [        R                  " U R                  SS9u  p#USU4   $ )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_transform(AgglomerationTransform.inverse_transform:   s0     			$,,tDg     N)__name__
__module____qualname____firstlineno____doc__r    r&   __static_attributes__r)   r(   r   r   r      s     Dr(   r   )r.   numpyr   scipy.sparser   sklearn.baser   sklearn.utils.validationr   r   r   r)   r(   r   <module>r4      s%     ! ) C9- 9r(   