`L iz NdZddlZddlmZddlmZddlmZm Z GddeZ y) zY Feature agglomeration. Base classes and functions for performing feature agglomeration. N)issparse)TransformerMixin)check_is_fitted validate_dataceZdZdZdZdZy)AgglomerationTransformzH A class for feature agglomeration via the transform interface. c t|t||d}|jtjk(rt |stj |j}|jd}tjt|Dcgc],}tj |j||ddf|z .c}}|Stj|jDcgc])}|j|dd|j|k(fd+}}tj|j}|Scc}wcc}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) A 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)resetrN)axis) rr pooling_funcnpmeanrbincountlabels_shapearrayrangeuniqueT)selfXsize n_samplesinXls l/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/cluster/_feature_agglomeration.py transformz AgglomerationTransform.transforms  $ /    ' ;;t||,D IDI)DTUqT\\1QT73d:UB 4<<0!!!At||q'8$8"9!BB"B Vs 1D8'.D=cnt|tj|jd\}}|d|fS)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.)rrrr)rrunilinverses rinverse_transformz(AgglomerationTransform.inverse_transform:s2  $,,tD ggN)__name__ __module__ __qualname____doc__r r%r&rr r s Dr&r ) r*numpyr scipy.sparserbaserutils.validationrrr r+r&rr0s%!#= 9-9r&