ó
    §ñ:i‘Á  ã                   óÂ  • S r SSKrSSKJrJrJr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JrJrJr  SS	KJr  SS
KJr  SSKJrJr  SSKJr  SSKJr  SSK J!r!J"r"J#r#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 r/S r0\%" S// SQ\#" \SSSS9S/S/S.SS9SSSS.S  j5       r1     S+S! jr2S" r3S# r4S$ r5\6" \1\3\4\5S%9r7S& r8 " S' S(\\5      r9 " S) S*\\9\.5      r:g),zíHierarchical Agglomerative Clustering

These routines perform some hierarchical agglomerative clustering of some
input data.

Authors : Vincent Michel, Bertrand Thirion, Alexandre Gramfort,
          Gael Varoquaux
License: BSD 3 clause
é    N)ÚheapifyÚheappopÚheappushÚheappushpop)ÚIntegralÚReal)Úsparse)Úconnected_componentsé   )ÚBaseEstimatorÚClassNamePrefixFeaturesOutMixinÚClusterMixinÚ_fit_context)ÚDistanceMetric)ÚMETRIC_MAPPING64)Ú_VALID_METRICSÚpaired_distances)Úcheck_array)ÚIntFloatDict)Ú
HasMethodsÚHiddenÚIntervalÚ
StrOptionsÚvalidate_params)Ú_fix_connected_components)Úcheck_memoryé   )Ú_hierarchical_fast)ÚAgglomerationTransformc           	      óð  • U R                   S   nUR                   S   U:w  d  UR                   S   U:w  a'  [        SUR                   < SU R                   < 35      eXR                  -   n[        R                  " U5      (       d  [        R
                  " U5      nUR                  S:w  a  UR                  5       n[        U5      u  pEUS:”  a&  [        R                  " SU-  SS9  [        U UUUUS	S
9nX4$ )aê  
Fixes the connectivity matrix.

The different steps are:

- copies it
- makes it symmetric
- converts it to LIL if necessary
- completes it if necessary.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Feature matrix representing `n_samples` samples to be clustered.

connectivity : sparse matrix, default=None
    Connectivity matrix. Defines for each sample the neighboring samples
    following a given structure of the data. The matrix is assumed to
    be symmetric and only the upper triangular half is used.
    Default is `None`, i.e, the Ward algorithm is unstructured.

affinity : {"euclidean", "precomputed"}, default="euclidean"
    Which affinity to use. At the moment `precomputed` and
    ``euclidean`` are supported. `euclidean` uses the
    negative squared Euclidean distance between points.

Returns
-------
connectivity : sparse matrix
    The fixed connectivity matrix.

n_connected_components : int
    The number of connected components in the graph.
r   r   z%Wrong shape for connectivity matrix: z when X is Úlilzxthe number of connected components of the connectivity matrix is %d > 1. Completing it to avoid stopping the tree early.r   ©Ú
stacklevelÚconnectivity)ÚXÚgraphÚn_connected_componentsÚcomponent_labelsÚmetricÚmode)ÚshapeÚ
ValueErrorÚTr	   ÚissparseÚ
lil_matrixÚformatÚtolilr
   ÚwarningsÚwarnr   )r%   r$   ÚaffinityÚ	n_samplesr'   Úlabelss         Úa/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/sklearn/cluster/_agglomerative.pyÚ_fix_connectivityr8   0   s  € ðF —‘˜‘
€IØ×Ñ˜!Ñ 	Ó)¨\×-?Ñ-?ÀÑ-BÀiÓ-OÝà×!Ô! 1§7£7ð,ó
ð 	
ð  §.¡.Ñ0€Lô �?Š?˜<×(Ñ(Ü×(Ò(¨Ó6ˆð ×Ñ˜eÓ#Ø#×)Ñ)Ó+ˆô &:¸,Ó%GÑ"Ðà Ó!Ü�Šð'à)?ñ@ð ò		
ô 1ØØØ#9Ø#ØØñ
ˆð Ð/Ð/ó    c                 ó†  • SSK Jn  U R                  [        R                  SS9n [        R
                  " U R                  R                  S9R                  nXpR                  U R                  S:H  '   U" U R                  5       5      nUR                  5       nSUR                  UR                  U:H  '   [        R                  " UR                  UR                  UR                  /5      R                  n	U	[        R                  " U	R                  S   SS9S	S	24   n	[         R"                  " U	5      n
U
S	S	2S	S24   R                  [$        5      n[        R&                  " U[        R(                  S9n[+        X±5       H&  u  nu  pïUb  XÒ:¼  a    OXâ:  a  XÜU'   Xò:  d  M"  XÜU'   M(     U(       a  U
S	S	2S4   nX´XU4$ X´X4$ )
zË
Perform single linkage clustering on sparse data via the minimum
spanning tree from scipy.sparse.csgraph, then using union-find to label.
The parent array is then generated by walking through the tree.
r   )Úminimum_spanning_treeF©Úcopy©Údtyper   Ú	mergesort©ÚkindN)Úscipy.sparse.csgraphr;   ÚastypeÚnpÚfloat64ÚfinfoÚdatar?   ÚepsÚtocsrÚtocooÚvstackÚrowÚcolr-   ÚargsortÚ_hierarchicalÚ_single_linkage_labelÚintÚarangeÚintpÚ	enumerate)r$   r5   Ún_nodesÚ
n_clustersr'   Úreturn_distancer;   Úepsilon_valueÚmstÚ	mst_arrayÚsingle_linkage_treeÚ	children_ÚparentÚiÚleftÚrightÚ	distancess                    r7   Ú_single_linkage_treerc   |   s�  € õ ;ð  ×&Ñ&¤r§z¡z¸Ð&Ð>€Lô —H’H <×#4Ñ#4×#:Ñ#:Ñ;×?Ñ?€MØ0=×Ñ�l×'Ñ'¨1Ñ,Ñ-ñ   × 2Ñ 2Ó 4Ó
5€Cð �)‰)‹+€Cð +,€C‡H�HˆS�X‰X˜Ñ&Ñ'ä—	’	˜3Ÿ7™7 C§G¡G¨S¯X©XÐ6Ó7×9Ñ9€Ið œ"Ÿ*š* Y§[¡[°¡^¸+ÑFÊÐIÑJ€Iô (×=Ò=¸iÓHÐØ#¢A r¨ r EÑ*×1Ñ1´#Ó6€Iô �YŠY�w¤b§g¡gÑ.€FÜ% iÖ;Ñˆ‰=ˆDØÑ! a£lÙØ‹>Ø�4‰LØ�?Ø�5‹Mñ <ö Ø'ª¨1¨Ñ-ˆ	Ø°)ÀYÐNÐNØ¨iÐ?Ð?r9   ú
array-like)rd   úsparse matrixNr`   ©ÚclosedÚboolean)r%   r$   rW   rX   T©Úprefer_skip_nested_validationF©r$   rW   rX   c                ó„
  • [         R                  " U 5      n U R                  S:X  a  [         R                  " U S5      n U R                  u  pEUc‰  SSKJn  Ub  [        R                  " SSS9  [         R                  " U S	S
9n UR                  U 5      nUSS2SS24   R                  [         R                  5      nU(       a  USS2S4   n	USUSU	4$ USUS4$ [        XSS9u  pUc	  SU-  S-
  nOX$:”  a  [        SX$4-  5      eSU-  U-
  n/ n/ n/ n[        UR                   5       H`  u  nnUR#                  U5        U Vs/ s H  nUU:  d  M  UPM     nnUR%                  ['        U5      U/-  5        UR%                  U5        Mb     [         R(                  " U[         R                  SS9n[         R(                  " U[         R                  SS9n[         R*                  " USS9nSUSU& [         R*                  " Xµ4SS9nU USU& [         R,                  " ['        U5      [         R.                  SS9n[0        R2                  " UUXÍU5        [5        [7        UXÍ5      5      n[9        U5        [         R:                  " U[         R                  S9n[         R<                  " U[>        S9n/ nU(       a  [         R,                  " X´-
  5      n	[         R,                  " U[>        SS9n[A        XK5       GHÜ  n [C        U5      u  nnnUU   (       a  UU   (       a  OM&  UUsUU'   UU'   UR#                  UU45        S=UU'   UU'   U(       a  UW	UU-
  '   UU   UU   -   UU'   UU   UU   -   UU'   / nURE                  S5        SUU'   [0        RF                  " UU   UUU5        [0        RF                  " UU   UUU5        U Vs/ s H  nUU   R#                  U5      PM       nUR#                  U5        [         R(                  " U[         R                  SS9n[         R,                  " UR                  [         R                  SS9nURE                  U5        ['        U5      n[         R,                  " U[         R.                  SS9n[0        R2                  " UUXÍU5        [A        U5       Vs/ s H  n[I        UUU   UUU   45      PM       nGMß     Un U V!s/ s H  n!U!SSS2   PM     nn![         R(                  " U5      nU(       a   [         RJ                  " SW	-  5      n	UU
U UU	4$ UU
U U4$ s  snf s  snf s  snf s  sn!f )a   Ward clustering based on a Feature matrix.

Recursively merges the pair of clusters that minimally increases
within-cluster variance.

The inertia matrix uses a Heapq-based representation.

This is the structured version, that takes into account some topological
structure between samples.

Read more in the :ref:`User Guide <hierarchical_clustering>`.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Feature matrix representing `n_samples` samples to be clustered.

connectivity : {array-like, sparse matrix}, default=None
    Connectivity matrix. Defines for each sample the neighboring samples
    following a given structure of the data. The matrix is assumed to
    be symmetric and only the upper triangular half is used.
    Default is None, i.e, the Ward algorithm is unstructured.

n_clusters : int, default=None
    `n_clusters` should be less than `n_samples`.  Stop early the
    construction of the tree at `n_clusters.` This is useful to decrease
    computation time if the number of clusters is not small compared to the
    number of samples. In this case, the complete tree is not computed, thus
    the 'children' output is of limited use, and the 'parents' output should
    rather be used. This option is valid only when specifying a connectivity
    matrix.

return_distance : bool, default=False
    If `True`, return the distance between the clusters.

Returns
-------
children : ndarray of shape (n_nodes-1, 2)
    The children of each non-leaf node. Values less than `n_samples`
    correspond to leaves of the tree which are the original samples.
    A node `i` greater than or equal to `n_samples` is a non-leaf
    node and has children `children_[i - n_samples]`. Alternatively
    at the i-th iteration, children[i][0] and children[i][1]
    are merged to form node `n_samples + i`.

n_connected_components : int
    The number of connected components in the graph.

n_leaves : int
    The number of leaves in the tree.

parents : ndarray of shape (n_nodes,) or None
    The parent of each node. Only returned when a connectivity matrix
    is specified, elsewhere 'None' is returned.

distances : ndarray of shape (n_nodes-1,)
    Only returned if `return_distance` is set to `True` (for compatibility).
    The distances between the centers of the nodes. `distances[i]`
    corresponds to a weighted Euclidean distance between
    the nodes `children[i, 1]` and `children[i, 2]`. If the nodes refer to
    leaves of the tree, then `distances[i]` is their unweighted Euclidean
    distance. Distances are updated in the following way
    (from scipy.hierarchy.linkage):

    The new entry :math:`d(u,v)` is computed as follows,

    .. math::

       d(u,v) = \sqrt{\frac{|v|+|s|}
                           {T}d(v,s)^2
                    + \frac{|v|+|t|}
                           {T}d(v,t)^2
                    - \frac{|v|}
                           {T}d(s,t)^2}

    where :math:`u` is the newly joined cluster consisting of
    clusters :math:`s` and :math:`t`, :math:`v` is an unused
    cluster in the forest, :math:`T=|v|+|s|+|t|`, and
    :math:`|*|` is the cardinality of its argument. This is also
    known as the incremental algorithm.

Examples
--------
>>> import numpy as np
>>> from sklearn.cluster import ward_tree
>>> X = np.array([[1, 2], [1, 4], [1, 0],
...               [4, 2], [4, 4], [4, 0]])
>>> children, n_connected_components, n_leaves, parents = ward_tree(X)
>>> children
array([[0, 1],
       [3, 5],
       [2, 6],
       [4, 7],
       [8, 9]])
>>> n_connected_components
1
>>> n_leaves
6
r   ©éÿÿÿÿr   Nr   ©Ú	hierarchyúâPartial build of the tree is implemented only for structured clustering (i.e. with explicit connectivity). The algorithm will build the full tree and only retain the lower branches required for the specified number of clustersr   r"   ÚW)ÚrequirementsÚ	euclidean©r4   z]Cannot provide more clusters than samples. %i n_clusters was asked, and there are %i samples.ÚC)r?   Úorder)rw   r>   Frn   g       @)&rE   ÚasarrayÚndimÚreshaper+   Úscipy.clusterrp   r2   r3   ÚrequireÚwardrD   rT   r8   r,   rU   ÚrowsÚappendÚextendÚlenÚarrayÚzerosÚemptyrF   rP   Úcompute_ward_distÚlistÚzipr   rS   ÚonesÚboolÚranger   ÚfillÚ_get_parentsr   Úsqrt)"r%   r$   rW   rX   r5   Ú
n_featuresrp   Úoutr]   rb   r'   rV   Ú	coord_rowÚ	coord_colÚAÚindrM   r_   Ú	moments_1Ú	moments_2Úinertiar^   Ú	used_nodeÚchildrenÚnot_visitedÚkÚinertÚjrN   Ún_additionsÚiniÚidxÚn_leavesÚcs"                                     r7   Ú	ward_treer¢   ¸   sý  € ôZ 	�
Š
�1‹€AØ‡v�v�ƒ{Ü�JŠJ�q˜'Ó"ˆØŸG™GÑ€IàÑÝ+àÑ!Ü�MŠMð;ð ò
ô �JŠJ�q sÑ+ˆØ�n‰n˜QÓˆØš˜2˜A˜2˜‘J×%Ñ%¤b§g¡gÓ.ˆ	æØšA˜q˜D™	ˆIØ˜a ¨D°)Ð;Ð;à˜a ¨DÐ0Ð0ä+<Ø	 +ñ,Ñ(€Lð ÑØ�i‘- !Ñ#‰àÓ!Üðà(Ð4ñ5óð ð
 �i‘- *Ñ,ˆð €IØ€IØ
€AÜ˜l×/Ñ/Ö0‰ˆˆSØ	�‰�Œñ Ó)š#�Q  S¡�q™#ˆÐ)Ø×ÑÜ�‹Hàðñô	
ð 	×Ñ˜Öñ 1ô —’˜¬"¯'©'¸Ñ=€IÜ—’˜¬"¯'©'¸Ñ=€Iô —’˜¨Ñ,€IØ€IˆjˆyÐÜ—’˜'Ð.°cÑ:€IØ€IˆjˆyÐÜ�hŠh”s˜9“~¬R¯Z©Z¸sÑC€GÜ×#Ò# I¨y¸)ÐPWÔXÜ”3�w 	Ó5Ó6€GÜˆGÔô �YŠY�w¤b§g¡gÑ.€FÜ—’˜¤tÑ,€IØ€HÞÜ—H’H˜WÑ0Ó1ˆ	ä—(’(˜7¬$°cÑ:€Kô �9×&ˆàÜ! 'Ó*‰KˆE�1�aØ˜�| 	¨!§Øñ ð  ! !Ðˆˆq‰	�6˜!‘9Ø�‰˜˜A˜ÔØ&+Ð+ˆ	�!‰�y ‘|ÞØ',ˆI�a˜)‘mÑ$ð ! ‘| i°¡lÑ2ˆ	�!‰Ø  ‘| i°¡lÑ2ˆ	�!‰ð ˆ	Ø×Ñ˜ÔØˆ�A‰Ü×"Ò" 1 Q¡4¨°F¸KÔHÜ×"Ò" 1 Q¡4¨°F¸KÔHá%.Ó/¢Y˜cˆˆ3‰�‰�qÖ	¡YÑ/Ø	�‰�ÔÜ—H’H˜Y¬b¯g©g¸SÑAˆ	Ü—H’H˜YŸ_™_´B·G±GÀ3ÑGˆ	Ø�‰�qÔÜ˜)“nˆÜ�hŠh�{¬"¯*©*¸CÑ@ˆä×'Ò'¨	°9¸iÐTWÔXô FKÈ;ÔEWÓXÒEW¸cŒ�'˜C ™H a¨°3©Ð8Ö	9ÑEWÔXñE 'ðJ €Há!)Ó*¢˜A�‘$�B�$”¡€HÐ*Ü�xŠx˜Ó!€Hæä—G’G˜C )™OÓ,ˆ	ØÐ/°¸6À9ÐLÐLàÐ/°¸6ÐAÐAùò_ *ùòn 	0ùò 	Yùò
 +s   Å
T.ÅT.ÏT3Ò+T8ÓT=c           
      óè  ^%• [         R                  " U 5      n U R                  S:X  a  [         R                  " U S5      n U R                  u  pg[
        R                  [
        R                  SS.n Xƒ   n	US:X  a:  [         R                  " [         R                  " U SS	9) 5      (       a  [        S
5      eUGcÚ  SSKJn  Ub  [        R                  " SSS9  US:X  ac  U R                  S   U R                  S   :w  a  [        SU R                   35      e[         R                   " U R                  S   SS9u  pÍXU4   n OTUS:X  a  SnOKUS;   a  SnOB[#        U5      (       a2  U" U 5      n [         R                   " U R                  S   SS9u  pÍXU4   n US:X  a¯  US:w  a©  [#        U5      (       d™  U[$        ;   a�  [&        R(                  " U5      n[         R*                  " U [         R,                  S9n [
        R.                  " X5      nU[         R0                  " UR2                  S   SS9SS24   n[
        R4                  " U5      nOUR7                  XUS9nUSS2SS24   R9                  [:        SS9nU(       a  USS2S4   nUSUSU4$ USUS4$ [=        XUS9u  nnUR?                  5       nUR@                  URB                  :g  nUR@                  U   Ul         URB                  U   Ul!        URD                  U   Ul"        AUS:X  a7  XR@                  URB                  4   R9                  [         RF                  SS9nO#[I        XR@                     XRB                     US9nUUl"        Uc	  SU-  S-
  nOX&::  d   eSU-  U-
  nUS:X  a  [K        UUUUUU5      $ U(       a  [         RL                  " UU-
  5      n[         RL                  " U[N        S9n[Q        5       nURS                  5       n[U        [W        URD                  URX                  5      5       H  u  m%u  nn[[        [         R                  " U[         R\                  S9[         R                  " U[         RF                  S95      UT%'   UR_                  U%4S  j[W        UU5       5       5        M�     A[a        U5        [         Rb                  " U[         R\                  S9n[         Rd                  " U[         R\                  S9n/ n[g        UU5       GH  n [i        U5      nUURj                     (       a  UURl                     (       a  OM6  URj                  nURl                  nU(       a  URn                  UUU-
  '   U=UU'   UU'   URq                  XÍ45        UU   nUU   n UU -   UU'   S=UU'   UU'   U	" UU   UU   UUU 5      n!U! H=  u  n"n#UU"   Rq                  UU#5        [s        U[
        Rt                  " U#UU"5      5        M?     U!UU'   S=UU'   UU'   GM     Un$[         Rv                  " U5      SS2SSS!24   nU(       a  UUU$UU4$ UUU$U4$ ! [         a(  n
[        SUR                  5       < SU< S35      U
eSn
A
ff = f)"a§  Linkage agglomerative clustering based on a Feature matrix.

The inertia matrix uses a Heapq-based representation.

This is the structured version, that takes into account some topological
structure between samples.

Read more in the :ref:`User Guide <hierarchical_clustering>`.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    Feature matrix representing `n_samples` samples to be clustered.

connectivity : sparse matrix, default=None
    Connectivity matrix. Defines for each sample the neighboring samples
    following a given structure of the data. The matrix is assumed to
    be symmetric and only the upper triangular half is used.
    Default is `None`, i.e, the Ward algorithm is unstructured.

n_clusters : int, default=None
    Stop early the construction of the tree at `n_clusters`. This is
    useful to decrease computation time if the number of clusters is
    not small compared to the number of samples. In this case, the
    complete tree is not computed, thus the 'children' output is of
    limited use, and the 'parents' output should rather be used.
    This option is valid only when specifying a connectivity matrix.

linkage : {"average", "complete", "single"}, default="complete"
    Which linkage criteria to use. The linkage criterion determines which
    distance to use between sets of observation.
        - "average" uses the average of the distances of each observation of
          the two sets.
        - "complete" or maximum linkage uses the maximum distances between
          all observations of the two sets.
        - "single" uses the minimum of the distances between all
          observations of the two sets.

affinity : str or callable, default='euclidean'
    Which metric to use. Can be 'euclidean', 'manhattan', or any
    distance known to paired distance (see metric.pairwise).

return_distance : bool, default=False
    Whether or not to return the distances between the clusters.

Returns
-------
children : ndarray of shape (n_nodes-1, 2)
    The children of each non-leaf node. Values less than `n_samples`
    correspond to leaves of the tree which are the original samples.
    A node `i` greater than or equal to `n_samples` is a non-leaf
    node and has children `children_[i - n_samples]`. Alternatively
    at the i-th iteration, children[i][0] and children[i][1]
    are merged to form node `n_samples + i`.

n_connected_components : int
    The number of connected components in the graph.

n_leaves : int
    The number of leaves in the tree.

parents : ndarray of shape (n_nodes, ) or None
    The parent of each node. Only returned when a connectivity matrix
    is specified, elsewhere 'None' is returned.

distances : ndarray of shape (n_nodes-1,)
    Returned when `return_distance` is set to `True`.

    distances[i] refers to the distance between children[i][0] and
    children[i][1] when they are merged.

See Also
--------
ward_tree : Hierarchical clustering with ward linkage.
r   rm   N)ÚcompleteÚaverageÚsinglez1Unknown linkage option, linkage should be one of z, but z
 was givenÚcosine)Úaxisz;Cosine affinity cannot be used when X contains zero vectorsr   ro   rq   r   r"   Úprecomputedz6Distance matrix should be square, got matrix of shape )rš   Úl2rt   )Úl1Ú	manhattanÚ	cityblockr¦   r>   r@   rA   )Úmethodr)   Fr<   ru   )r)   c              3   óh   >#   • U  H'  u  pUT:  d  M  [         R                  " UTU5      v •  M)     g 7f©N)rP   ÚWeightedEdge)Ú.0ÚrÚdr“   s      €r7   Ú	<genexpr>Úlinkage_tree.<locals>.<genexpr>‡  s4   øé € ð 
Ú>L±d°aÐPQÐTWÑPWÓ1ŒM×&Ò& q¨#¨q×1Ð1ºnùs   ƒ2“2rn   )<rE   rx   ry   rz   r+   rP   Ú	max_mergeÚaverage_mergeÚKeyErrorr,   ÚkeysÚanyr{   rp   r2   r3   Útriu_indicesÚcallabler   r   Ú
get_metricÚascontiguousarrayÚdoubleÚmst_linkage_corerO   r-   Úsingle_linkage_labelÚlinkagerD   rR   r8   rK   rM   rN   rH   rF   r   rc   r„   Úobjectr†   r1   rU   r‡   r~   r   rT   r€   r   rS   rˆ   rŠ   r   ÚaÚbÚweightr   r   r±   r‚   )&r%   r$   rW   rÃ   r4   rX   r5   rŽ   Úlinkage_choicesÚ	join_funcÚerp   r_   rœ   Údist_metricrZ   r�   r]   rb   r'   Ú	diag_maskrV   r’   r–   rH   rM   r^   r—   r˜   rš   ÚedgeÚn_iÚn_jr‘   rN   r´   r    r“   s&                                        @r7   Úlinkage_treerÐ   ¬  sF  ø€ ôf 	�
Š
�1‹€AØ‡v�v�ƒ{Ü�JŠJ�q˜'Ó"ˆØŸG™GÑ€Iô "×+Ñ+Ü ×.Ñ.Øñ€Oð
Ø#Ñ,ˆ	ð �8Ó¤§¢¬¯ª¨q°qÑ(9Ð'9× :Ñ :ÜÐVÓWÐWàÒÝ+àÑ!Ü�MŠMð;ð ò
ð �}Ó$ð �w‰w�q‰z˜QŸW™W Q™ZÓ'Ü ØLÈQÏWÉWÈIÐVóð ô —?’? 1§7¡7¨1¡:°Ñ3‰DˆAØ�Q�$‘‰AØ˜Óà"‰HØÐ,Ó,Ø"‰HÜ�h×ÑÙ˜“ˆAÜ—?’? 1§7¡7¨1¡:°Ñ3‰DˆAØ�Q�$‘ˆAà�xÓØ˜MÓ)Ü˜X×&Ñ&ØÔ,Ó,ô )×3Ò3°HÓ=ˆKô ×$Ò$ Q¬b¯i©iÑ8ˆAä×0Ò0°Ó@ˆCà”b—j’j §¡ q¡°Ñ<ºaÐ?Ñ@ˆCô  ×4Ò4°SÓ9‰Cà×#Ñ# A¸hÐ#ÐGˆCØš˜2˜A˜2˜‘J×%Ñ%¤c°Ð%Ð6ˆ	æØšA˜q˜D™	ˆIØ˜a ¨D°)Ð;Ð;Ø˜!˜Y¨Ð,Ð,ä+<Ø	 (ñ,Ñ(€LÐ(ð  ×%Ñ%Ó'€Là× Ñ  L×$4Ñ$4Ñ4€IØ#×'Ñ'¨	Ñ2€LÔØ#×'Ñ'¨	Ñ2€LÔØ$×)Ñ)¨)Ñ4€LÔØà�=Ó Ø×&Ñ&¨×(8Ñ(8Ð8Ñ9×@Ñ@ÄÇÁÐRWÐ@ÐX‰	ô %Ø×ÑÑ ×#3Ñ#3Ñ!4¸Xñ
ˆ	ð "€LÔàÑØ�i‘- !Ñ#‰àÓ&Ð&Ð&Ø�i‘- *Ñ,ˆà�(ÓÜ#ØØØØØ"Øó
ð 	
ö Ü—H’H˜W yÑ0Ó1ˆ	ä
�Š�¤Ñ'€AÜ‹f€Gð  ×%Ñ%Ó'€Lä%¤c¨,×*;Ñ*;¸\×=NÑ=NÓ&OÖPÑˆ‰[ˆd�CÜÜ�JŠJ�s¤"§'¡'Ñ*¬B¯JªJ°tÄ2Ç:Á:Ñ,Nó
ˆˆ#‰ð
 	�‰ô 
Ü>AÀ#Àt¼nó
ö 	
ñ Qð 	äˆGÔô �YŠY�w¤b§g¡gÑ.€FÜ—’˜¤r§w¡wÑ/€IØ€Hô �9˜g×&ˆàÜ˜7Ó#ˆDØ˜Ÿ™×  Y¨t¯v©v×%6Øñ ð �F‰FˆØ�F‰Fˆæà'+§{¡{ˆI�a˜)‘mÑ$à !Ð!ˆˆq‰	�F˜1‘IØ�‰˜˜Ôà˜‰lˆØ˜‰lˆØ˜S‘yˆ	�!‰Ø&+Ð+ˆ	�!‰�y ‘|ñ ˜a ™d A a¡D¨)°S¸#Ó>ˆ	Û‰FˆC�Øˆc‰F�M‰M˜!˜QÔô �Wœm×8Ò8¸¸A¸sÓCÖDñ	  ð
 ˆˆ!‰àˆˆˆ!‰ˆq�Œtñ? 'ðD €Hô �xŠx˜Ó!¢!¡T r T 'Ñ*€HæØÐ/°¸6À9ÐLÐLØÐ+¨X°vÐ=Ð=øôe ó Ýà×#Ñ#Ö%£wð0ó
ð ð	ûðús   Á0X? Ø?
Y1Ù	#Y,Ù,Y1c                  ó"   • SUS'   [        U 0 UD6$ )Nr¤   rÃ   ©rÐ   ©ÚargsÚkwargss     r7   Ú_complete_linkagerÖ   Á  s   € Ø"€Fˆ9ÑÜ˜Ð( Ñ(Ð(r9   c                  ó"   • SUS'   [        U 0 UD6$ )Nr¥   rÃ   rÒ   rÓ   s     r7   Ú_average_linkagerØ   Æ  s   € Ø!€Fˆ9ÑÜ˜Ð( Ñ(Ð(r9   c                  ó"   • SUS'   [        U 0 UD6$ )Nr¦   rÃ   rÒ   rÓ   s     r7   Ú_single_linkagerÚ   Ë  s   € Ø €Fˆ9ÑÜ˜Ð( Ñ(Ð(r9   )r}   r¤   r¥   r¦   c                 óx  • X:”  a  [        SU  SU S35      e[        US   5      S-   * /n[        U S-
  5       H,  nXS   * U-
     n[        X5S   * 5        [	        X5S   * 5        M.     [
        R                  " U[
        R                  S9n[        U5       H  u  pxXv[        R                  " U* X5      '   M!     U$ )a½  Function cutting the ward tree for a given number of clusters.

Parameters
----------
n_clusters : int or ndarray
    The number of clusters to form.

children : ndarray of shape (n_nodes-1, 2)
    The children of each non-leaf node. Values less than `n_samples`
    correspond to leaves of the tree which are the original samples.
    A node `i` greater than or equal to `n_samples` is a non-leaf
    node and has children `children_[i - n_samples]`. Alternatively
    at the i-th iteration, children[i][0] and children[i][1]
    are merged to form node `n_samples + i`.

n_leaves : int
    Number of leaves of the tree.

Returns
-------
labels : array [n_samples]
    Cluster labels for each point.
z+Cannot extract more clusters than samples: z% clusters were given for a tree with z leaves.rn   r   r   r>   )r,   ÚmaxrŠ   r   r   rE   rƒ   rT   rU   rP   Ú_hc_get_descendent)	rW   r˜   r    ÚnodesÚ_Úthese_childrenÚlabelr_   Únodes	            r7   Ú_hc_cutrã   Û  sÒ   € ð0 ÓÜØ9ØˆlÐ?À¸zÈðSó
ð 	
ô �8˜B‘<Ó  1Ñ$Ð%Ð&€EÜ�: ‘>Ö"ˆà!¨¡8 )¨hÑ"6Ñ7ˆä�¨Ñ*Ð*Ô+Ü�E¨1Ñ-Ð-Ö.ñ #ô �HŠH�X¤R§W¡WÑ-€EÜ˜UÖ#‰ˆØMNŒm×.Ò.°¨u°hÓIÓJñ $à€Lr9   c                   óN  ^ • \ rS rSr% Sr\" \SSSS9S/\" \" \	5      S1-  5      \
\" S5      /\\" S5      S/S	S
\
S/\" S15      S/\" \" \R                  5       5      5      /\" \SSSS9S/S/S.r\\S'    SSSSSSSSS.S jjr\" SS9SS j5       rS rSU 4S jjrSrU =r$ )ÚAgglomerativeClusteringi  aÒ  
Agglomerative Clustering.

Recursively merges pair of clusters of sample data; uses linkage distance.

Read more in the :ref:`User Guide <hierarchical_clustering>`.

Parameters
----------
n_clusters : int or None, default=2
    The number of clusters to find. It must be ``None`` if
    ``distance_threshold`` is not ``None``.

metric : str or callable, default="euclidean"
    Metric used to compute the linkage. Can be "euclidean", "l1", "l2",
    "manhattan", "cosine", or "precomputed". If linkage is "ward", only
    "euclidean" is accepted. If "precomputed", a distance matrix is needed
    as input for the fit method.

    .. versionadded:: 1.2

    .. deprecated:: 1.4
       `metric=None` is deprecated in 1.4 and will be removed in 1.6.
       Let `metric` be the default value (i.e. `"euclidean"`) instead.

memory : str or object with the joblib.Memory interface, default=None
    Used to cache the output of the computation of the tree.
    By default, no caching is done. If a string is given, it is the
    path to the caching directory.

connectivity : array-like, sparse matrix, or callable, default=None
    Connectivity matrix. Defines for each sample the neighboring
    samples following a given structure of the data.
    This can be a connectivity matrix itself or a callable that transforms
    the data into a connectivity matrix, such as derived from
    `kneighbors_graph`. Default is ``None``, i.e, the
    hierarchical clustering algorithm is unstructured.

    For an example of connectivity matrix using
    :class:`~sklearn.neighbors.kneighbors_graph`, see
    :ref:`sphx_glr_auto_examples_cluster_plot_agglomerative_clustering.py`.

compute_full_tree : 'auto' or bool, default='auto'
    Stop early the construction of the tree at ``n_clusters``. This is
    useful to decrease computation time if the number of clusters is not
    small compared to the number of samples. This option is useful only
    when specifying a connectivity matrix. Note also that when varying the
    number of clusters and using caching, it may be advantageous to compute
    the full tree. It must be ``True`` if ``distance_threshold`` is not
    ``None``. By default `compute_full_tree` is "auto", which is equivalent
    to `True` when `distance_threshold` is not `None` or that `n_clusters`
    is inferior to the maximum between 100 or `0.02 * n_samples`.
    Otherwise, "auto" is equivalent to `False`.

linkage : {'ward', 'complete', 'average', 'single'}, default='ward'
    Which linkage criterion to use. The linkage criterion determines which
    distance to use between sets of observation. The algorithm will merge
    the pairs of cluster that minimize this criterion.

    - 'ward' minimizes the variance of the clusters being merged.
    - 'average' uses the average of the distances of each observation of
      the two sets.
    - 'complete' or 'maximum' linkage uses the maximum distances between
      all observations of the two sets.
    - 'single' uses the minimum of the distances between all observations
      of the two sets.

    .. versionadded:: 0.20
        Added the 'single' option

    For examples comparing different `linkage` criteria, see
    :ref:`sphx_glr_auto_examples_cluster_plot_linkage_comparison.py`.

distance_threshold : float, default=None
    The linkage distance threshold at or above which clusters will not be
    merged. If not ``None``, ``n_clusters`` must be ``None`` and
    ``compute_full_tree`` must be ``True``.

    .. versionadded:: 0.21

compute_distances : bool, default=False
    Computes distances between clusters even if `distance_threshold` is not
    used. This can be used to make dendrogram visualization, but introduces
    a computational and memory overhead.

    .. versionadded:: 0.24

    For an example of dendrogram visualization, see
    :ref:`sphx_glr_auto_examples_cluster_plot_agglomerative_dendrogram.py`.

Attributes
----------
n_clusters_ : int
    The number of clusters found by the algorithm. If
    ``distance_threshold=None``, it will be equal to the given
    ``n_clusters``.

labels_ : ndarray of shape (n_samples)
    Cluster labels for each point.

n_leaves_ : int
    Number of leaves in the hierarchical tree.

n_connected_components_ : int
    The estimated number of connected components in the graph.

    .. versionadded:: 0.21
        ``n_connected_components_`` was added to replace ``n_components_``.

n_features_in_ : int
    Number of features seen during :term:`fit`.

    .. versionadded:: 0.24

feature_names_in_ : ndarray of shape (`n_features_in_`,)
    Names of features seen during :term:`fit`. Defined only when `X`
    has feature names that are all strings.

    .. versionadded:: 1.0

children_ : array-like of shape (n_samples-1, 2)
    The children of each non-leaf node. Values less than `n_samples`
    correspond to leaves of the tree which are the original samples.
    A node `i` greater than or equal to `n_samples` is a non-leaf
    node and has children `children_[i - n_samples]`. Alternatively
    at the i-th iteration, children[i][0] and children[i][1]
    are merged to form node `n_samples + i`.

distances_ : array-like of shape (n_nodes-1,)
    Distances between nodes in the corresponding place in `children_`.
    Only computed if `distance_threshold` is used or `compute_distances`
    is set to `True`.

See Also
--------
FeatureAgglomeration : Agglomerative clustering but for features instead of
    samples.
ward_tree : Hierarchical clustering with ward linkage.

Examples
--------
>>> from sklearn.cluster import AgglomerativeClustering
>>> import numpy as np
>>> X = np.array([[1, 2], [1, 4], [1, 0],
...               [4, 2], [4, 4], [4, 0]])
>>> clustering = AgglomerativeClustering().fit(X)
>>> clustering
AgglomerativeClustering()
>>> clustering.labels_
array([1, 1, 1, 0, 0, 0])
r   Nr`   rf   r©   Úcacherd   re   Úautorh   r   )rW   r)   Úmemoryr$   Úcompute_full_treerÃ   Údistance_thresholdÚcompute_distancesÚ_parameter_constraintsrt   r}   F)r)   rè   r$   ré   rÃ   rê   rë   c                ód   • Xl         Xpl        X0l        X@l        XPl        X`l        X l        X€l        g r°   )rW   rê   rè   r$   ré   rÃ   r)   rë   )	ÚselfrW   r)   rè   r$   ré   rÃ   rê   rë   s	            r7   Ú__init__Ú AgglomerativeClustering.__init__µ  s0   € ð %ŒØ"4ÔØŒØ(ÔØ!2ÔØŒØŒØ!2Õr9   Tri   c                 óD   • U R                  USS9nU R                  U5      $ )a   Fit the hierarchical clustering from features, or distance matrix.

Parameters
----------
X : array-like, shape (n_samples, n_features) or                 (n_samples, n_samples)
    Training instances to cluster, or distances between instances if
    ``metric='precomputed'``.

y : Ignored
    Not used, present here for API consistency by convention.

Returns
-------
self : object
    Returns the fitted instance.
r   )Úensure_min_samples)Ú_validate_dataÚ_fit)rî   r%   Úys      r7   ÚfitÚAgglomerativeClustering.fitÊ  s'   € ð& ×Ñ °aÐÐ8ˆØ�y‰y˜‹|Ðr9   c                 ób  • [        U R                  5      nU R                  c#  [        R                  " S[
        5        SU l        OU R                  U l        U R                  SL U R                  SL -  (       d  [        S5      eU R                  b  U R                  (       d  [        S5      eU R                  S:X  a(  U R                  S:w  a  [        U R                   S35      e[        U R                     nU R                  nU R                  b7  [        U R                  5      (       a  U R                  U5      n[        U/ SQS	9n[!        U5      nU R                  nU R                  c  S
nUS:X  a,  U R                  b  S
nOU R                  [#        SSU-  5      :  nU R                  nU(       a  Sn0 nU R                  S:w  a  U R                  US'   U R                  US'   U R                  n	U	SL=(       d    U R$                  n
UR'                  U5      " U4UUU
S.UD6nUSS u  U l        U l        U l        nU
(       a
  US   U l        U R                  b,  [0        R2                  " U R.                  U	:¬  5      S-   U l        OU R                  U l        U(       a2  [7        U R4                  U R(                  U R,                  5      U l        U $ [:        R<                  " USS9n[0        R>                  " USU 5      n[0        R@                  " [0        RB                  " U5      U5      U l        U $ )a  Fit without validation

Parameters
----------
X : ndarray of shape (n_samples, n_features) or (n_samples, n_samples)
    Training instances to cluster, or distances between instances if
    ``metric='precomputed'``.

Returns
-------
self : object
    Returns the fitted instance.
NzŽ`metric=None` is deprecated in version 1.4 and will be removed in version 1.6. Let `metric` be the default value (i.e. `'euclidean'`) instead.rt   z_Exactly one of n_clusters and distance_threshold has to be set, and the other needs to be None.z<compute_full_tree must be True if distance_threshold is set.r}   zE was provided as metric. Ward can only work with euclidean distances.)ÚcsrÚcoor!   )Úaccept_sparseTrç   éd   g{®Gáz”?rÃ   r4   rk   é   rn   r   Fr<   )"r   rè   r)   r2   r3   ÚFutureWarningÚ_metricrW   rê   r,   ré   rÃ   Ú_TREE_BUILDERSr$   r½   r   r�   rÜ   rë   ræ   r]   Ún_connected_components_Ú	n_leaves_Ú
distances_rE   Úcount_nonzeroÚn_clusters_rã   Úlabels_rP   Úhc_get_headsr=   ÚsearchsortedÚunique)rî   r%   rè   Útree_builderr$   r5   ré   rW   rÕ   rê   rX   r�   Úparentsr6   s                 r7   rô   ÚAgglomerativeClustering._fità  s  € ô ˜dŸk™kÓ*ˆð �;‰;ÑÜ�MŠMð4ô ôð 'ˆD�LàŸ;™;ˆDŒLà—‘ DÐ(¨T×-DÑ-DÈÐ-L×MÜð$óð ð ×"Ñ"Ñ.°t×7M×7MÜØNóð ð �<‰<˜6Ó! d§l¡l°kÓ&AÜØ—<‘<�.ð !1ð 1óð ô
 & d§l¡lÑ3ˆà×(Ñ(ˆØ×ÑÑ(Ü˜×)Ñ)×*Ñ*Ø#×0Ñ0°Ó3�Ü&ØÒ,AñˆLô ˜“Fˆ	Ø ×2Ñ2ÐØ×ÑÑ$Ø $ÐØ Ó&Ø×&Ñ&Ñ2Ø$(Ñ!ð
 %)§O¡O´c¸#¸tÀiÑ?OÓ6PÑ$PÐ!Ø—_‘_ˆ
ÞØˆJð ˆØ�<‰<˜6Ó!Ø $§¡ˆF�9ÑØ!%§¡ˆF�:Ñà!×4Ñ4Ðà-°TÐ9×T¸d×>TÑ>Tˆà�l‰l˜<Ô(Øð
à%Ø!Ø+ñ	
ð
 ñ
ˆð SVØˆQðS
ÑOˆŒ˜Ô5°t´~Àwö Ø! "™gˆDŒOà×"Ñ"Ñ.ä× Ò  §¡Ð4FÑ!FÓGÈ!ÑKð Õð  $Ÿ™ˆDÔö Ü" 4×#3Ñ#3°T·^±^ÀTÇ^Á^ÓTˆDŒLð ˆô #×/Ò/°¸eÑDˆFä—W’W˜V J YÐ/Ó0ˆFäŸ?š?¬2¯9ª9°VÓ+<¸fÓEˆDŒLØˆr9   c                 ó"   >• [         TU ]  X5      $ )a-  Fit and return the result of each sample's clustering assignment.

In addition to fitting, this method also return the result of the
clustering assignment for each sample in the training set.

Parameters
----------
X : array-like of shape (n_samples, n_features) or                 (n_samples, n_samples)
    Training instances to cluster, or distances between instances if
    ``affinity='precomputed'``.

y : Ignored
    Not used, present here for API consistency by convention.

Returns
-------
labels : ndarray of shape (n_samples,)
    Cluster labels.
)ÚsuperÚfit_predict©rî   r%   rõ   Ú	__class__s      €r7   r  Ú#AgglomerativeClustering.fit_predictT  s   ø€ ô* ‰wÑ" 1Ó(Ð(r9   )rÿ   r]   rë   ré   r$   rê   r  r  rÃ   rè   r)   rW   r  r  r  ©r   r°   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   Úsetr   r½   r   Ústrr   r   rº   r   rì   ÚdictÚ__annotations__rï   r   rö   rô   r  Ú__static_attributes__Ú__classcell__©r  s   @r7   rå   rå     sþ   ø‡ ñVñr   ¨!¨T¸&ÑAÀ4ÐHá‘s˜>Ó*¨m¨_Ñ<Ó=ØÙ�4‹Lð
ð
 ™
 7Ó+¨TÐ2Ø% ¸À$ÐGÙ(¨&¨Ó2°IÐ>Ù™s >×#6Ñ#6Ó#8Ó9Ó:Ð;Ù'¨¨a°¸fÑEÀtÐLØ'˜[ñ$Ð˜Dó ð" ð3ð ØØØ ØØØö3ñ* °Ñ5óó 6ðò*r÷h)õ )r9   rå   c                   ón  ^ • \ rS rSr% Sr\" \SSSS9S/\" \" \	5      S1-  5      \
\" S5      /\\" S5      S/S	S
\
S/\" S15      S/\" \" \R                  5       5      5      /\
/\" \SSSS9S/S/S.	r\\S'    SSSSSS\R*                  SSS.U 4S jjjr\" SS9SU 4S jj5       r\S 5       rSrU =r$ )ÚFeatureAgglomerationil  aÈ  Agglomerate features.

Recursively merges pair of clusters of features.

Read more in the :ref:`User Guide <hierarchical_clustering>`.

Parameters
----------
n_clusters : int or None, default=2
    The number of clusters to find. It must be ``None`` if
    ``distance_threshold`` is not ``None``.

metric : str or callable, default="euclidean"
    Metric used to compute the linkage. Can be "euclidean", "l1", "l2",
    "manhattan", "cosine", or "precomputed". If linkage is "ward", only
    "euclidean" is accepted. If "precomputed", a distance matrix is needed
    as input for the fit method.

    .. versionadded:: 1.2

    .. deprecated:: 1.4
       `metric=None` is deprecated in 1.4 and will be removed in 1.6.
       Let `metric` be the default value (i.e. `"euclidean"`) instead.

memory : str or object with the joblib.Memory interface, default=None
    Used to cache the output of the computation of the tree.
    By default, no caching is done. If a string is given, it is the
    path to the caching directory.

connectivity : array-like, sparse matrix, or callable, default=None
    Connectivity matrix. Defines for each feature the neighboring
    features following a given structure of the data.
    This can be a connectivity matrix itself or a callable that transforms
    the data into a connectivity matrix, such as derived from
    `kneighbors_graph`. Default is `None`, i.e, the
    hierarchical clustering algorithm is unstructured.

compute_full_tree : 'auto' or bool, default='auto'
    Stop early the construction of the tree at `n_clusters`. This is useful
    to decrease computation time if the number of clusters is not small
    compared to the number of features. This option is useful only when
    specifying a connectivity matrix. Note also that when varying the
    number of clusters and using caching, it may be advantageous to compute
    the full tree. It must be ``True`` if ``distance_threshold`` is not
    ``None``. By default `compute_full_tree` is "auto", which is equivalent
    to `True` when `distance_threshold` is not `None` or that `n_clusters`
    is inferior to the maximum between 100 or `0.02 * n_samples`.
    Otherwise, "auto" is equivalent to `False`.

linkage : {"ward", "complete", "average", "single"}, default="ward"
    Which linkage criterion to use. The linkage criterion determines which
    distance to use between sets of features. The algorithm will merge
    the pairs of cluster that minimize this criterion.

    - "ward" minimizes the variance of the clusters being merged.
    - "complete" or maximum linkage uses the maximum distances between
      all features of the two sets.
    - "average" uses the average of the distances of each feature of
      the two sets.
    - "single" uses the minimum of the distances between all features
      of the two sets.

pooling_func : callable, default=np.mean
    This combines the values of agglomerated features into a single
    value, and should accept an array of shape [M, N] and the keyword
    argument `axis=1`, and reduce it to an array of size [M].

distance_threshold : float, default=None
    The linkage distance threshold at or above which clusters will not be
    merged. If not ``None``, ``n_clusters`` must be ``None`` and
    ``compute_full_tree`` must be ``True``.

    .. versionadded:: 0.21

compute_distances : bool, default=False
    Computes distances between clusters even if `distance_threshold` is not
    used. This can be used to make dendrogram visualization, but introduces
    a computational and memory overhead.

    .. versionadded:: 0.24

Attributes
----------
n_clusters_ : int
    The number of clusters found by the algorithm. If
    ``distance_threshold=None``, it will be equal to the given
    ``n_clusters``.

labels_ : array-like of (n_features,)
    Cluster labels for each feature.

n_leaves_ : int
    Number of leaves in the hierarchical tree.

n_connected_components_ : int
    The estimated number of connected components in the graph.

    .. versionadded:: 0.21
        ``n_connected_components_`` was added to replace ``n_components_``.

n_features_in_ : int
    Number of features seen during :term:`fit`.

    .. versionadded:: 0.24

feature_names_in_ : ndarray of shape (`n_features_in_`,)
    Names of features seen during :term:`fit`. Defined only when `X`
    has feature names that are all strings.

    .. versionadded:: 1.0

children_ : array-like of shape (n_nodes-1, 2)
    The children of each non-leaf node. Values less than `n_features`
    correspond to leaves of the tree which are the original samples.
    A node `i` greater than or equal to `n_features` is a non-leaf
    node and has children `children_[i - n_features]`. Alternatively
    at the i-th iteration, children[i][0] and children[i][1]
    are merged to form node `n_features + i`.

distances_ : array-like of shape (n_nodes-1,)
    Distances between nodes in the corresponding place in `children_`.
    Only computed if `distance_threshold` is used or `compute_distances`
    is set to `True`.

See Also
--------
AgglomerativeClustering : Agglomerative clustering samples instead of
    features.
ward_tree : Hierarchical clustering with ward linkage.

Examples
--------
>>> import numpy as np
>>> from sklearn import datasets, cluster
>>> digits = datasets.load_digits()
>>> images = digits.images
>>> X = np.reshape(images, (len(images), -1))
>>> agglo = cluster.FeatureAgglomeration(n_clusters=32)
>>> agglo.fit(X)
FeatureAgglomeration(n_clusters=32)
>>> X_reduced = agglo.transform(X)
>>> X_reduced.shape
(1797, 32)
r   Nr`   rf   r©   ræ   rd   re   rç   rh   r   )	rW   r)   rè   r$   ré   rÃ   Úpooling_funcrê   rë   rì   rt   r}   F)r)   rè   r$   ré   rÃ   r"  rê   rë   c                ó:   >• [         T
U ]  UUUUUUUU	S9  Xpl        g )N)rW   rè   r$   ré   rÃ   r)   rê   rë   )r  rï   r"  )rî   rW   r)   rè   r$   ré   rÃ   r"  rê   rë   r  s             €r7   rï   ÚFeatureAgglomeration.__init__  s7   ø€ ô 	‰ÑØ!ØØ%Ø/ØØØ1Ø/ð 	ñ 		
ð )Õr9   Tri   c                 ó|   >• U R                  USS9n[        TU ]	  UR                  5        U R                  U l        U $ )a	  Fit the hierarchical clustering on the data.

Parameters
----------
X : array-like of shape (n_samples, n_features)
    The data.

y : Ignored
    Not used, present here for API consistency by convention.

Returns
-------
self : object
    Returns the transformer.
r   )Úensure_min_features)ró   r  rô   r-   r  Ú_n_features_outr  s      €r7   rö   ÚFeatureAgglomeration.fit)  s=   ø€ ð" ×Ñ °qÐÐ9ˆÜ‰‰�Q—S‘SÔØ#×/Ñ/ˆÔØˆr9   c                 ó   • [         e)zAFit and return the result of each sample's clustering assignment.)ÚAttributeError)rî   s    r7   r  Ú FeatureAgglomeration.fit_predict?  s
   € ô Ðr9   )r'  r"  r  r°   )r  r  r  r  r  r   r   r   r  r   r½   r   r  r   r   rº   r   rì   r  r  rE   Úmeanrï   r   rö   Úpropertyr  r  r  r  s   @r7   r!  r!  l  s  ø‡ ñOñd   ¨!¨T¸&ÑAÀ4ÐHá‘s˜>Ó*¨m¨_Ñ<Ó=ØÙ�4‹Lð
ð
 ™
 7Ó+¨TÐ2Ø% ¸À$ÐGÙ(¨&¨Ó2°IÐ>Ù™s >×#6Ñ#6Ó#8Ó9Ó:Ð;Ø!˜
Ù'¨¨a°¸fÑEÀtÐLØ'˜[ñ$Ð˜Dó ð$ ð)ð ØØØ ØØ—W‘WØØ÷)ñ )ñ2 °Ñ5öó 6ðð* ñó ör9   r!  )NNr¤   rt   F);r  r2   Úheapqr   r   r   r   Únumbersr   r   ÚnumpyrE   Úscipyr	   rC   r
   Úbaser   r   r   r   Úmetricsr   Úmetrics._dist_metricsr   Úmetrics.pairwiser   r   Úutilsr   Úutils._fast_dictr   Úutils._param_validationr   r   r   r   r   Úutils.graphr   Úutils.validationr   Ú r   rP   Ú_feature_agglomerationr   r8   rc   r¢   rÐ   rÖ   rØ   rÚ   r  r   rã   rå   r!  © r9   r7   Ú<module>r>     s   ðñó ß 9Ó 9ß "ã Ý Ý 5÷ó õ %Ý 4ß ?Ý Ý +÷õ õ 4Ý +õ 2Ý :òI0òX5@ñx àˆ^Ú=Ù ¨!¨T¸&ÑAÀ4ÐHØ%˜;ñ	ð #'ñð "&°$Èô gBóðgBðZ ØØØØôQ>òj)ò
)ò
)ñ
 Ø	ØØØñ	€ò,ôd\)˜l¨Mô \)ô~
VØ#Ð%<Ð>TõVr9   