ó
    §ñ:iLW  ã                   ó  • S r SSKJrJr  SSKJr  SSKrSSKJ	r	  SSK
JrJr  SSKJrJr  SS	KJrJrJr  SS
KJrJr  SSKJrJr  SSKJrJrJr  SSKJr  SSK J!r!J"r"  SS/r#S r$SS jr%S r& " S S\\\S9r' " S S\'5      r( " S S\'5      r)g)z!Spectral biclustering algorithms.é    )ÚABCMetaÚabstractmethod)ÚIntegralN)Únorm)Ú
dia_matrixÚissparse)ÚeigshÚsvdsé   )ÚBaseEstimatorÚBiclusterMixinÚ_fit_context)Úcheck_random_stateÚcheck_scalar)ÚIntervalÚ
StrOptions)Úmake_nonnegativeÚrandomized_svdÚsafe_sparse_dot)Úassert_all_finiteé   )ÚKMeansÚMiniBatchKMeansÚSpectralCoclusteringÚSpectralBiclusteringc           	      ó®  • [        U 5      n [        R                  " S[        R                  " U R	                  SS95      -  5      R                  5       n[        R                  " S[        R                  " U R	                  SS95      -  5      R                  5       n[        R                  " [        R                  " U5      SU5      n[        R                  " [        R                  " U5      SU5      n[        U 5      (       a2  U R                  u  p4[        US/4X34S9n[        US/4XD4S9nXP-  U-  nOUSS2[        R                  4   U -  U-  nXqU4$ )z‚Normalize ``X`` by scaling rows and columns independently.

Returns the normalized matrix and the row and column scaling
factors.
g      ð?r   ©Úaxisr   )ÚshapeN)r   ÚnpÚasarrayÚsqrtÚsumÚsqueezeÚwhereÚisnanr   r   r   Únewaxis)ÚXÚrow_diagÚcol_diagÚn_rowsÚn_colsÚrÚcÚans           Ú]/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/sklearn/cluster/_bicluster.pyÚ_scale_normalizer1      s  € ô 	˜Ó€AÜ�zŠz˜#¤§¢¨¯©°1¨¨Ó 6Ñ6Ó7×?Ñ?ÓA€HÜ�zŠz˜#¤§¢¨¯©°1¨¨Ó 6Ñ6Ó7×?Ñ?ÓA€HÜ�xŠxœŸš Ó*¨A¨xÓ8€HÜ�xŠxœŸš Ó*¨A¨xÓ8€HÜ�‡{�{ØŸ™‰ˆÜ˜ 1 #�¨vÐ.>Ñ?ˆÜ˜ 1 #�¨vÐ.>Ñ?ˆØ‰U�Q‰Y‰à’aœŸ™�mÑ$ qÑ(¨8Ñ3ˆØ˜Ð!Ð!ó    c                 ó   • [        U 5      n U n[        U5       Ha  n[        U5      u  n  n[        U 5      (       a#  [	        UR
                  U R
                  -
  5      nO[	        X5-
  5      nUnUc  MY  Xb:  d  M`    U$    U$ )z…Normalize rows and columns of ``X`` simultaneously so that all
rows sum to one constant and all columns sum to a different
constant.
)r   Úranger1   r   r   Údata)r(   Úmax_iterÚtolÚX_scaledÚ_ÚX_newÚdists          r0   Ú_bistochastic_normalizer<   -   s|   € ô 	˜Ó€AØ€HÜ�8Ž_ˆÜ& xÓ0‰ˆˆq�!Ü�A�;‰;Ü˜Ÿ™¨¯©Ñ.Ó/‰Dä˜Ñ(Ó)ˆDØˆØÓ ¥
ØØ€Oñ ð €Or2   c                 ó  • [        U SS9n [        U 5      (       a  [        S5      e[        R                  " U 5      nUR                  SS9SS2[        R                  4   nUR                  SS9nUR                  5       nX-
  U-
  U-   $ )z>Normalize ``X`` according to Kluger's log-interactions scheme.r   )Ú	min_valuez[Cannot compute log of a sparse matrix, because log(x) diverges to -infinity as x goes to 0.r   Nr   )r   r   Ú
ValueErrorr    ÚlogÚmeanr'   )r(   ÚLÚrow_avgÚcol_avgÚavgs        r0   Ú_log_normalizerF   B   s€   € ä˜ aÑ(€AÜ�‡{�{Üðó
ð 	
ô
 	�Šˆq‹	€AØ�f‰f˜!ˆfˆnšQ¤§
¡
˜]Ñ+€GØ�f‰f˜!ˆfˆn€GØ
�&‰&‹(€CØ‰;˜Ñ  3Ñ&Ð&r2   c                   óö   • \ rS rSr% Sr\" SS15      /\" \SSSS9S/S	/\" S
S15      \R                  /\" \SSSS9/S/S.r
\\S'   \       SS j5       r\S 5       r\" SS9SS j5       rS rS rS rSrg)ÚBaseSpectraléR   z%Base class for spectral biclustering.Ú
randomizedÚarpackr   NÚleft©ÚclosedÚbooleanú	k-means++Úrandomr   Úrandom_state©Ú
svd_methodÚ
n_svd_vecsÚ
mini_batchÚinitÚn_initrR   Ú_parameter_constraintsc                 óX   • Xl         X l        X0l        X@l        XPl        X`l        Xpl        g ©N)Ú
n_clustersrT   rU   rV   rW   rX   rR   )Úselfr\   rT   rU   rV   rW   rX   rR   s           r0   Ú__init__ÚBaseSpectral.__init__^   s(   € ð %ŒØ$ŒØ$ŒØ$ŒØŒ	ØŒØ(Õr2   c                 ó   • g)z0Validate parameters depending on the input data.N© ©r]   Ú	n_sampless     r0   Ú_check_parametersÚBaseSpectral._check_parametersq   s   � r2   T)Úprefer_skip_nested_validationc                 ó¢   • U R                  US[        R                  S9nU R                  UR                  S   5        U R                  U5        U $ )zÿCreate a biclustering for X.

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

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

Returns
-------
self : object
    SpectralBiclustering instance.
Úcsr)Úaccept_sparseÚdtyper   )Ú_validate_datar    Úfloat64rd   r   Ú_fit)r]   r(   Úys      r0   ÚfitÚBaseSpectral.fitu   sE   € ð" ×Ñ °¼b¿j¹jÐÐIˆØ×Ñ˜qŸw™w q™zÔ*Ø�	‰	�!ŒØˆr2   c                 ó¢  • U R                   S:X  a;  0 nU R                  b  U R                  US'   [        X4SU R                  0UD6u  pVnGOSU R                   S:X  GaB  [	        XU R                  S9u  pVn[
        R                  " [
        R                  " U5      5      (       am  [        UR                  U5      n[        U R                  5      n	U	R                  SSUR                  S	   5      n
[        X€R                  U
S
9u  pkUR                  n[
        R                  " [
        R                  " U5      5      (       a`  [        XR                  5      n[        U R                  5      n	U	R                  SSUR                  S	   5      n
[        X€R                  U
S
9u  pe[        W5        [        W5        USS2US24   nXsS nXWR                  4$ )zhReturns first `n_components` left and right singular
vectors u and v, discarding the first `n_discard`.
rJ   NÚn_oversamplesrR   rK   )ÚkÚncvéÿÿÿÿr   r   )rt   Úv0)rT   rU   r   rR   r
   r    Úanyr&   r   ÚTr   Úuniformr   r	   r   )r]   ÚarrayÚn_componentsÚ	n_discardÚkwargsÚur9   ÚvtÚArR   rv   Úvs               r0   Ú_svdÚBaseSpectral._svd‹   s}  € ð �?‰?˜lÓ*ØˆFØ�‰Ñ*Ø*.¯/©/��Ñ'Ü%ØñØ26×2CÑ2CðØGMñ‰HˆA’"ð �_‰_ Ô(Ü˜E°t·±ÑG‰HˆA�"Ü�vŠv”b—h’h˜r“l×#Ñ#ô $ E§G¡G¨UÓ3�Ü1°$×2CÑ2CÓD�à!×)Ñ)¨"¨a°·±¸±Ó<�Ü˜Q§O¡O¸Ñ;‘�Ø—S‘S�Ü�vŠv”b—h’h˜q“k×"Ñ"Ü# E¯7©7Ó3�Ü1°$×2CÑ2CÓD�à!×)Ñ)¨"¨a°·±¸±Ó<�Ü˜Q§O¡O¸Ñ;‘�ä˜!ÔÜ˜"ÔØŠa�‘ˆmÑˆØ�
ˆ^ˆØ—$‘$ˆwˆr2   c                 ó&  • U R                   (       a+  [        UU R                  U R                  U R                  S9nO*[        UU R                  U R                  U R                  S9nUR                  U5        UR                  nUR                  nXE4$ )N)rW   rX   rR   )	rV   r   rW   rX   rR   r   ro   Úcluster_centers_Úlabels_)r]   r5   r\   ÚmodelÚcentroidÚlabelss         r0   Ú_k_meansÚBaseSpectral._k_means°   s}   € Ø�?�?Ü#ØØ—Y‘YØ—{‘{Ø!×.Ñ.ñ	‰Eô ØØ—Y‘YØ—{‘{Ø!×.Ñ.ñ	ˆEð 	�	‰	�$ŒØ×)Ñ)ˆØ—‘ˆØÐÐr2   c           
      ó   • SSSSSSSSSS.0$ )NÚ_xfail_checkszraises nan errorz_scale_normalize failszraises apply_along_axis errorzdoes not fail gracefullyzempty array passed inside)Úcheck_estimators_dtypesÚcheck_fit2d_1sampleÚcheck_fit2d_1featureÚcheck_estimator_sparse_matrixÚcheck_estimator_sparse_arrayÚcheck_methods_subset_invarianceÚcheck_dont_overwrite_parametersÚcheck_fit2d_predict1dra   )r]   s    r0   Ú
_more_tagsÚBaseSpectral._more_tagsÄ   s,   € àØ+=Ø'?Ø(GØ1KØ0JØ3NØ3NØ)Dñ	ð
ð 	
r2   )rW   rV   r\   rX   rU   rR   rT   )é   rJ   NFrP   é
   Nr[   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r    ÚndarrayrY   ÚdictÚ__annotations__r   r^   rd   r   ro   r‚   rŠ   r–   Ú__static_attributes__ra   r2   r0   rH   rH   R   sÓ   ‡ Ù/ñ " <°Ð":Ó;Ð<Ù ¨!¨T¸&ÑAÀ4ÐHØ �kÙ˜[¨(Ð3Ó4°b·j±jÐAÙ˜H a¨°fÑ=Ð>Ø'Ð(ñ$Ð˜Dó ð ð ØØØØØØó)ó ð)ð$ ñ?ó ð?ñ °Ñ5óó 6ðò*#òJ õ(
r2   rH   )Ú	metaclassc            	       ó�   ^ • \ rS rSr% Sr0 \R                  ES\" \SSSS9/0Er\	\
S'    SS	SS
SSSS.U 4S jjjrS rS rSrU =r$ )r   éÓ   aj  Spectral Co-Clustering algorithm (Dhillon, 2001).

Clusters rows and columns of an array `X` to solve the relaxed
normalized cut of the bipartite graph created from `X` as follows:
the edge between row vertex `i` and column vertex `j` has weight
`X[i, j]`.

The resulting bicluster structure is block-diagonal, since each
row and each column belongs to exactly one bicluster.

Supports sparse matrices, as long as they are nonnegative.

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

Parameters
----------
n_clusters : int, default=3
    The number of biclusters to find.

svd_method : {'randomized', 'arpack'}, default='randomized'
    Selects the algorithm for finding singular vectors. May be
    'randomized' or 'arpack'. If 'randomized', use
    :func:`sklearn.utils.extmath.randomized_svd`, which may be faster
    for large matrices. If 'arpack', use
    :func:`scipy.sparse.linalg.svds`, which is more accurate, but
    possibly slower in some cases.

n_svd_vecs : int, default=None
    Number of vectors to use in calculating the SVD. Corresponds
    to `ncv` when `svd_method=arpack` and `n_oversamples` when
    `svd_method` is 'randomized`.

mini_batch : bool, default=False
    Whether to use mini-batch k-means, which is faster but may get
    different results.

init : {'k-means++', 'random'}, or ndarray of shape             (n_clusters, n_features), default='k-means++'
    Method for initialization of k-means algorithm; defaults to
    'k-means++'.

n_init : int, default=10
    Number of random initializations that are tried with the
    k-means algorithm.

    If mini-batch k-means is used, the best initialization is
    chosen and the algorithm runs once. Otherwise, the algorithm
    is run for each initialization and the best solution chosen.

random_state : int, RandomState instance, default=None
    Used for randomizing the singular value decomposition and the k-means
    initialization. Use an int to make the randomness deterministic.
    See :term:`Glossary <random_state>`.

Attributes
----------
rows_ : array-like of shape (n_row_clusters, n_rows)
    Results of the clustering. `rows[i, r]` is True if
    cluster `i` contains row `r`. Available only after calling ``fit``.

columns_ : array-like of shape (n_column_clusters, n_columns)
    Results of the clustering, like `rows`.

row_labels_ : array-like of shape (n_rows,)
    The bicluster label of each row.

column_labels_ : array-like of shape (n_cols,)
    The bicluster label of each column.

biclusters_ : tuple of two ndarrays
    The tuple contains the `rows_` and `columns_` arrays.

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

See Also
--------
SpectralBiclustering : Partitions rows and columns under the assumption
    that the data has an underlying checkerboard structure.

References
----------
* :doi:`Dhillon, Inderjit S, 2001. Co-clustering documents and words using
  bipartite spectral graph partitioning.
  <10.1145/502512.502550>`

Examples
--------
>>> from sklearn.cluster import SpectralCoclustering
>>> import numpy as np
>>> X = np.array([[1, 1], [2, 1], [1, 0],
...               [4, 7], [3, 5], [3, 6]])
>>> clustering = SpectralCoclustering(n_clusters=2, random_state=0).fit(X)
>>> clustering.row_labels_ #doctest: +SKIP
array([0, 1, 1, 0, 0, 0], dtype=int32)
>>> clustering.column_labels_ #doctest: +SKIP
array([0, 0], dtype=int32)
>>> clustering
SpectralCoclustering(n_clusters=2, random_state=0)
r\   r   NrL   rM   rY   rJ   FrP   r™   rS   c          	      ó*   >• [         TU ]  XX4XVU5        g r[   )Úsuperr^   )	r]   r\   rT   rU   rV   rW   rX   rR   Ú	__class__s	           €r0   r^   ÚSpectralCoclustering.__init__F  s   ø€ ô 	‰ÑØ J¸DÈ,õ	
r2   c                 ó\   • U R                   U:”  a  [        SU SU R                    S35      eg )Nú"n_clusters should be <= n_samples=ú. Got ú	 instead.)r\   r?   rb   s     r0   rd   Ú&SpectralCoclustering._check_parametersU  s>   € Ø�?‰?˜YÓ&ÜØ4°Y°Kð @Ø—O‘OÐ$ Ið/óð ð 'r2   c                 ó  • [        U5      u  p#nS[        [        R                  " [        R                  " U R
                  5      5      5      -   nU R                  X%SS9u  pg[        R                  " US S 2[        R                  4   U-  US S 2[        R                  4   U-  45      nU R                  X€R
                  5      u  pšUR                  S   nU
S U U l        X«S  U l        [        R                  " [        U R
                  5       Vs/ s H  oÀR                  U:H  PM     sn5      U l        [        R                  " [        U R
                  5       Vs/ s H  oÀR                  U:H  PM     sn5      U l        g s  snf s  snf )Nr   )r|   r   )r1   Úintr    ÚceilÚlog2r\   r‚   Úvstackr'   rŠ   r   Úrow_labels_Úcolumn_labels_r4   Úrows_Úcolumns_)r]   r(   Únormalized_datar)   r*   Ún_svr~   r�   Úzr9   r‰   r+   r.   s                r0   rm   ÚSpectralCoclustering._fit\  s.  € Ü.>¸qÓ.AÑ+ˆ 8Ø”3”r—w’wœrŸwšw t§¡Ó7Ó8Ó9Ñ9ˆØ�y‰y˜¸!ˆyÐ<‰ˆÜ�IŠI�x¢¤2§:¡: Ñ.°Ñ2°HºQÄÇ
Á
¸]Ñ4KÈaÑ4OÐPÓQˆà—M‘M !§_¡_Ó5‰	ˆà—‘˜‘ˆØ! ' 6˜?ˆÔØ$ W˜oˆÔä—Y’Y¼uÀTÇ_Á_Ô?UÓVÒ?U¸!× 0Ñ 0°AÔ 5Ñ?UÑVÓWˆŒ
ÜŸ	š	Ü/4°T·_±_Ô/EÓFÒ/E¨!× Ñ  AÔ%Ñ/EÑFó
ˆ�ùò  WùâFs   ÄE?ÅF)rµ   r·   r´   r¶   ©r˜   )rš   r›   rœ   r�   rž   rH   rY   r   r   r    r¡   r^   rd   rm   r¢   Ú__classcell__©r¨   s   @r0   r   r   Ó   sv   ø‡ ñkðZ$Ø
×
-Ñ
-ð$à‘x ¨!¨T¸&ÑAÐBñ$Ð˜Dó ð ð
ð  ØØØØØ÷
ñ 
ò÷
ð 
r2   c                   óÜ   ^ • \ rS rSr% Sr0 \R                  E\" \SSSS9\	/\
" 1 Sk5      /\" \SSSS9/\" \SSSS9/S.Er\\S	'    SSSS
SSSSSSS.	U 4S jjjrS rS rS rS rSrU =r$ )r   in  aô  Spectral biclustering (Kluger, 2003).

Partitions rows and columns under the assumption that the data has
an underlying checkerboard structure. For instance, if there are
two row partitions and three column partitions, each row will
belong to three biclusters, and each column will belong to two
biclusters. The outer product of the corresponding row and column
label vectors gives this checkerboard structure.

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

Parameters
----------
n_clusters : int or tuple (n_row_clusters, n_column_clusters), default=3
    The number of row and column clusters in the checkerboard
    structure.

method : {'bistochastic', 'scale', 'log'}, default='bistochastic'
    Method of normalizing and converting singular vectors into
    biclusters. May be one of 'scale', 'bistochastic', or 'log'.
    The authors recommend using 'log'. If the data is sparse,
    however, log normalization will not work, which is why the
    default is 'bistochastic'.

    .. warning::
       if `method='log'`, the data must not be sparse.

n_components : int, default=6
    Number of singular vectors to check.

n_best : int, default=3
    Number of best singular vectors to which to project the data
    for clustering.

svd_method : {'randomized', 'arpack'}, default='randomized'
    Selects the algorithm for finding singular vectors. May be
    'randomized' or 'arpack'. If 'randomized', uses
    :func:`~sklearn.utils.extmath.randomized_svd`, which may be faster
    for large matrices. If 'arpack', uses
    `scipy.sparse.linalg.svds`, which is more accurate, but
    possibly slower in some cases.

n_svd_vecs : int, default=None
    Number of vectors to use in calculating the SVD. Corresponds
    to `ncv` when `svd_method=arpack` and `n_oversamples` when
    `svd_method` is 'randomized`.

mini_batch : bool, default=False
    Whether to use mini-batch k-means, which is faster but may get
    different results.

init : {'k-means++', 'random'} or ndarray of shape (n_clusters, n_features),             default='k-means++'
    Method for initialization of k-means algorithm; defaults to
    'k-means++'.

n_init : int, default=10
    Number of random initializations that are tried with the
    k-means algorithm.

    If mini-batch k-means is used, the best initialization is
    chosen and the algorithm runs once. Otherwise, the algorithm
    is run for each initialization and the best solution chosen.

random_state : int, RandomState instance, default=None
    Used for randomizing the singular value decomposition and the k-means
    initialization. Use an int to make the randomness deterministic.
    See :term:`Glossary <random_state>`.

Attributes
----------
rows_ : array-like of shape (n_row_clusters, n_rows)
    Results of the clustering. `rows[i, r]` is True if
    cluster `i` contains row `r`. Available only after calling ``fit``.

columns_ : array-like of shape (n_column_clusters, n_columns)
    Results of the clustering, like `rows`.

row_labels_ : array-like of shape (n_rows,)
    Row partition labels.

column_labels_ : array-like of shape (n_cols,)
    Column partition labels.

biclusters_ : tuple of two ndarrays
    The tuple contains the `rows_` and `columns_` arrays.

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

See Also
--------
SpectralCoclustering : Spectral Co-Clustering algorithm (Dhillon, 2001).

References
----------

* :doi:`Kluger, Yuval, et. al., 2003. Spectral biclustering of microarray
  data: coclustering genes and conditions.
  <10.1101/gr.648603>`

Examples
--------
>>> from sklearn.cluster import SpectralBiclustering
>>> import numpy as np
>>> X = np.array([[1, 1], [2, 1], [1, 0],
...               [4, 7], [3, 5], [3, 6]])
>>> clustering = SpectralBiclustering(n_clusters=2, random_state=0).fit(X)
>>> clustering.row_labels_
array([1, 1, 1, 0, 0, 0], dtype=int32)
>>> clustering.column_labels_
array([1, 0], dtype=int32)
>>> clustering
SpectralBiclustering(n_clusters=2, random_state=0)

For a more detailed example, see
:ref:`sphx_glr_auto_examples_bicluster_plot_spectral_biclustering.py`
r   NrL   rM   >   r@   ÚscaleÚbistochastic)r\   Úmethodr{   Ún_bestrY   r˜   rÁ   é   rJ   FrP   r™   )	rÂ   r{   rÃ   rT   rU   rV   rW   rX   rR   c       	   	      óN   >• [         TU ]  XXgX‰U
5        X l        X0l        X@l        g r[   )r§   r^   rÂ   r{   rÃ   )r]   r\   rÂ   r{   rÃ   rT   rU   rV   rW   rX   rR   r¨   s              €r0   r^   ÚSpectralBiclustering.__init__ö  s-   ø€ ô 	‰ÑØ J¸DÈ,ô	
ð ŒØ(ÔØ�r2   c                 óâ  • [        U R                  [        5      (       a-  U R                  U:”  a  [        SU SU R                   S35      eO1 U R                  u  p#[	        US[        SUS9  [	        US[        SUS9  U R                  U R                  :”  a&  [        S
U R                   SU R                   S35      eg ! [        [
        4 a  n[        SU R                   S	35      UeS nAff = f)Nr«   r¬   r­   Ún_row_clustersr   )Útarget_typeÚmin_valÚmax_valÚn_column_clustersz*Incorrect parameter n_clusters has value: z¦. It should either be a single integer or an iterable with two integers: (n_row_clusters, n_column_clusters) And the values are should be in the range: (1, n_samples)zn_best=z must be <= n_components=Ú.)Ú
isinstancer\   r   r?   r   Ú	TypeErrorrÃ   r{   )r]   rc   rÈ   rÌ   Úes        r0   rd   Ú&SpectralBiclustering._check_parameters  s  € Ü�d—o‘o¤x×0Ñ0Ø�‰ Ó*Ü Ø8¸¸ð DØŸ™Ð(¨	ð3óð ð +ðØ48·O±OÑ1�ÜØ"Ø$Ü (ØØ%òô Ø%Ø'Ü (ØØ%òð" �;‰;˜×*Ñ*Ó*ÜØ˜$Ÿ+™+˜Ð&?À×@QÑ@QÐ?RÐRSÐTóð ð +øô ¤	Ð*ó Ü ðØŸ™Ð(ð )-ð-óð ðûðús   Á0B? Â?C.ÃC)Ã)C.c           	      ó6  • U R                   nU R                  S:X  a  [        U5      nUS-  nO@U R                  S:X  a  [        U5      u  n  nUS-  nOU R                  S:X  a  [	        U5      nU R                  S:X  a  SOSnU R                  WX%5      u  pgUR                  nUR                  n	 U R                  u  p«U R                  X€R                  U
5      nU R                  X�R                  U5      nU R                  XR                  U
5      U l        U R                  UR                  UR                  U5      U l        [        R                  " [!        U
5       VVs/ s H%  n[!        U5        H  nU R                  U:H  PM     M'     snn5      U l        [        R                  " [!        U
5       VVs/ s H%  n[!        U5        H  nU R                  U:H  PM     M'     snn5      U l        g ! [         a    U R                  =p« GNNf = fs  snnf s  snnf )NrÁ   r   rÀ   r@   r   )r{   rÂ   r<   r1   rF   r‚   rx   r\   rÏ   Ú_fit_best_piecewiserÃ   Ú_project_and_clusterr´   rµ   r    r³   r4   r¶   r·   )r]   r(   r¹   r¸   r9   r|   r~   r�   Úutr   rÈ   Ún_col_clustersÚbest_utÚbest_vtÚlabels                  r0   rm   ÚSpectralBiclustering._fit2  sÝ  € Ø× Ñ ˆØ�;‰;˜.Ó(Ü5°aÓ8ˆOØ�A‰I‰DØ�[‰[˜GÓ#Ü$4°QÓ$7Ñ!ˆO˜Q Ø�A‰I‰DØ�[‰[˜EÓ!Ü,¨QÓ/ˆOØŸ™¨Ó-‘A°1ˆ	Ø�y‰y˜¨$Ó:‰ˆØ�S‰SˆØ�S‰Sˆð	>Ø-1¯_©_Ñ*ˆNð ×*Ñ*¨2¯{©{¸NÓKˆà×*Ñ*¨2¯{©{¸NÓKˆà×4Ñ4°Q¿	¹	À>ÓRˆÔà"×7Ñ7¸¿¹¸W¿Y¹YÈÓWˆÔä—Y’Yô # >Ô2ôâ2�EÜ˜~×.�Að × Ñ  EÔ)á.ñ *Ù2òó
ˆŒ
ô Ÿ	š	ô ˜~Ô.ôâ.�AÜ" >×2�Eð ×#Ñ# uÔ,á2ñ -Ù.òó
ˆ�øô% ó 	>Ø.2¯o©oÐ=ˆNš^ð	>üóùós   Â/G1 Å ,H
Æ7,H
Ç1HÈHc                 ó´   ^ ^• UU 4S jn[         R                  " USUS9n[         R                  " [        SX-
  S9nU[         R                  " U5      SU    nU$ )z¸Find the ``n_best`` vectors that are best approximated by piecewise
constant vectors.

The piecewise vectors are found by k-means; the best is chosen
according to Euclidean distance.

c                 óp   >• TR                  U R                  SS5      T5      u  pX   R                  5       $ )Nru   r   )rŠ   ÚreshapeÚravel)r�   rˆ   r‰   r\   r]   s      €€r0   Úmake_piecewiseÚ@SpectralBiclustering._fit_best_piecewise.<locals>.make_piecewisef  s3   ø€ Ø#Ÿ}™}¨Q¯Y©Y°r¸1Ó-=¸zÓJÑˆHØÑ#×)Ñ)Ó+Ð+r2   r   )r   ÚarrN)r    Úapply_along_axisr   Úargsort)r]   ÚvectorsrÃ   r\   rß   Úpiecewise_vectorsÚdistsÚresults   `  `    r0   rÓ   Ú(SpectralBiclustering._fit_best_piecewise]  sU   ù€ ö	,ô ×/Ò/°ÀQÈGÑTÐÜ×#Ò#¤D¨q°wÑ7RÑTˆØœŸš EÓ*¨7¨FÐ3Ñ4ˆØˆr2   c                 óB   • [        X5      nU R                  XC5      u  pVU$ )z7Project ``data`` to ``vectors`` and cluster the result.)r   rŠ   )r]   r5   rä   r\   Ú	projectedr9   r‰   s          r0   rÔ   Ú)SpectralBiclustering._project_and_clustero  s!   € ä# DÓ2ˆ	Ø—M‘M )Ó8‰	ˆØˆr2   )rµ   r·   rÂ   rÃ   r{   r´   r¶   r¼   )rš   r›   rœ   r�   rž   rH   rY   r   r   Útupler   r    r¡   r^   rd   rm   rÓ   rÔ   r¢   r½   r¾   s   @r0   r   r   n  s¹   ø‡ ñ}ð~$Ø
×
-Ñ
-ð$á ¨!¨T¸&ÑAÀ5ÐIÙÒ>Ó?Ð@Ù! (¨A¨t¸FÑCÐDÙ˜H a¨°fÑ=Ð>ò$Ð˜Dó ð ðð ØØØØØØØØ÷ñ ò*%òN)
òV÷$ð r2   )iè  gñhãˆµøä>)*rž   Úabcr   r   Únumbersr   Únumpyr    Úscipy.linalgr   Úscipy.sparser   r   Úscipy.sparse.linalgr	   r
   Úbaser   r   r   Úutilsr   r   Úutils._param_validationr   r   Úutils.extmathr   r   r   Úutils.validationr   Ú_kmeansr   r   Ú__all__r1   r<   rF   rH   r   r   ra   r2   r0   Ú<module>rú      s~   ðÙ '÷
 (Ý ã Ý ß -ß +ç >Ñ >ß 4ß :ß MÑ MÝ 0ß ,à!Ð#9Ð
:€ò"ô*ò*'ô ~
�> =¸Gò ~
ôBX
˜<ô X
ôvE˜<õ Er2   