Ë
    ÷Q(h:  ã                   ó”   — d dl Zd dlmZ ddlmZmZ ddlmZm	Z	 dgZ
d„ Zd„ Zd	„ Z eegege ed
h«      gdœd¬«      d
dœd„«       Zy)é    N)Úlinear_sum_assignmenté   )Ú
StrOptionsÚvalidate_params)Úcheck_arrayÚcheck_consistent_lengthÚconsensus_scorec                 óp   — t        | Ž  t        |Ž  d„ }t        || «      \  }}t        ||«      \  }}||||fS )z9Unpacks the row and column arrays and checks their shape.c                 ó   — t        | d¬«      S )NF)Ú	ensure_2d)r   )Úxs    ú`/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sklearn/metrics/cluster/_bicluster.pyú<lambda>z)_check_rows_and_columns.<locals>.<lambda>   s   € ”{ 1°Ô6€ ó    )r   Úmap)ÚaÚbÚchecksÚa_rowsÚa_colsÚb_rowsÚb_colss          r   Ú_check_rows_and_columnsr      sD   € ä˜QÑÜ˜QÑÙ6€FÜ˜ “^�N€FˆFÜ˜ “^�N€FˆFØ�6˜6 6Ð)Ð)r   c                 óê   — | |z  j                  «       ||z  j                  «       z  }| j                  «       |j                  «       z  }|j                  «       |j                  «       z  }|||z   |z
  z  S )z:Jaccard coefficient on the elements of the two biclusters.)Úsum)r   r   r   r   ÚintersectionÚa_sizeÚb_sizes          r   Ú_jaccardr      sf   € à˜V‘O×(Ñ(Ó*¨f°v©o×-BÑ-BÓ-DÑD€Là�Z‰Z‹\˜FŸJ™J›LÑ(€FØ�Z‰Z‹\˜FŸJ™J›LÑ(€Fà˜6 F™?¨\Ñ9Ñ:Ð:r   c                 ó.  — t        | |«      \  }}}}|j                  d   }|j                  d   }t        j                  t	        |«      D �	�
cg c]0  }	t	        |«      D �
cg c]  }
 |||	   ||	   ||
   ||
   «      ‘Œ c}
‘Œ2 c}
}	«      }|S c c}
w c c}
}	w )zƒComputes pairwise similarity matrix.

    result[i, j] is the Jaccard coefficient of a's bicluster i and b's
    bicluster j.

    r   )r   ÚshapeÚnpÚarrayÚrange)r   r   Ú
similarityr   r   r   r   Ún_aÚn_bÚiÚjÚresults               r   Ú_pairwise_similarityr+   !   sœ   € ô &=¸QÀÓ%BÑ"€FˆF�F˜FØ
�,‰,�q‰/€CØ
�,‰,�q‰/€CÜ�X‰Xô ˜3“Z÷	
àô NSÐSVËZÖXÈ‰Z˜˜q™	 6¨!¡9¨f°Q©i¸À¹ÕCÔXó	
ó€Fð €Mùò	 Yùó	
s   ÁB
ÁBÁ=B
ÂB
Újaccard)r   r   r%   T)Úprefer_skip_nested_validation)r%   c                óÐ   — |dk(  rt         }t        | ||«      }t        d|z
  «      \  }}t        | d   «      }t        |d   «      }|||f   j	                  «       t        ||«      z  S )ad  The similarity of two sets of biclusters.

    Similarity between individual biclusters is computed. Then the best
    matching between sets is found by solving a linear sum assignment problem,
    using a modified Jonker-Volgenant algorithm.
    The final score is the sum of similarities divided by the size of
    the larger set.

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

    Parameters
    ----------
    a : tuple (rows, columns)
        Tuple of row and column indicators for a set of biclusters.

    b : tuple (rows, columns)
        Another set of biclusters like ``a``.

    similarity : 'jaccard' or callable, default='jaccard'
        May be the string "jaccard" to use the Jaccard coefficient, or
        any function that takes four arguments, each of which is a 1d
        indicator vector: (a_rows, a_columns, b_rows, b_columns).

    Returns
    -------
    consensus_score : float
       Consensus score, a non-negative value, sum of similarities
       divided by size of larger set.

    See Also
    --------
    scipy.optimize.linear_sum_assignment : Solve the linear sum assignment problem.

    References
    ----------
    * Hochreiter, Bodenhofer, et. al., 2010. `FABIA: factor analysis
      for bicluster acquisition
      <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2881408/>`__.

    Examples
    --------
    >>> from sklearn.metrics import consensus_score
    >>> a = ([[True, False], [False, True]], [[False, True], [True, False]])
    >>> b = ([[False, True], [True, False]], [[True, False], [False, True]])
    >>> consensus_score(a, b, similarity='jaccard')
    np.float64(1.0)
    r,   g      ð?r   )r   r+   r   Úlenr   Úmax)r   r   r%   ÚmatrixÚrow_indicesÚcol_indicesr&   r'   s           r   r	   r	   4   sq   € ðp �YÒÜˆ
Ü! ! Q¨
Ó3€FÜ4°S¸6±\ÓBÑ€K�Ü
ˆa�‰d‹)€CÜ
ˆa�‰d‹)€CØ�+˜{Ð*Ñ+×/Ñ/Ó1´C¸¸S³MÑAÐAr   )Únumpyr"   Úscipy.optimizer   Úutils._param_validationr   r   Úutils.validationr   r   Ú__all__r   r   r+   ÚtupleÚcallabler	   © r   r   ú<module>r<      sm   ðó Ý 0ç Bß DàÐ
€ò*ò;òñ& àˆWØˆWØ¡¨Y¨KÓ!8Ð9ñð
 #'ôð )2ó 6Bóñ6Br   