§
    rŠtj?  ã                   ó¨   — 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dS )é    N)Úlinear_sum_assignment)Ú
StrOptionsÚvalidate_params)Úcheck_arrayÚcheck_consistent_lengthÚconsensus_scorec                 ó„   — 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/html/CA-Chatbot/venv/lib/python3.11/site-packages/sklearn/metrics/cluster/_bicluster.pyú<lambda>z)_check_rows_and_columns.<locals>.<lambda>   s   € •{ 1°Ð6Ñ6Ô6€ ó    )r   Úmap)ÚaÚbÚchecksÚa_rowsÚa_colsÚb_rowsÚb_colss          r   Ú_check_rows_and_columnsr      sQ   € å˜QÐÐÝ˜QÐÐØ6Ð6€FÝ˜ ‘^”^�N€FˆFÝ˜ ‘^”^�N€FˆFØ�6˜6 6Ð)Ð)r   c                 ó  — | |z                        ¦   «         ||z                        ¦   «         z  }|                       ¦   «         |                      ¦   «         z  }|                      ¦   «         |                      ¦   «         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      st   € à˜V‘O×(Ò(Ñ*Ô*¨f°v©o×-BÒ-BÑ-DÔ-DÑD€Là�ZŠZ‰\Œ\˜FŸJšJ™LœLÑ(€FØ�ZŠZ‰\Œ\˜FŸJšJ™LœLÑ(€Fà˜6 F™?¨\Ñ9Ñ:Ð:r   c                 óÔ   ‡‡‡‡‡‡	— t          | |¦  «        \  ŠŠŠŠ‰j        d         }‰j        d         Š	t          j        ˆˆˆˆˆ	ˆfd„t	          |¦  «        D ¦   «         ¦  «        }|S )zƒComputes pairwise similarity matrix.

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

    r   c                 óR   •‡— g | ]"Šˆˆˆˆˆˆfd „t          ‰¦  «        D ¦   «         ‘Œ#S )c           	      ó\   •— g | ](} ‰‰‰         ‰‰         ‰|         ‰|         ¦  «        ‘Œ)S © r"   )Ú.0Újr   r   r   r   ÚiÚ
similaritys     €€€€€€r   ú
<listcomp>z3_pairwise_similarity.<locals>.<listcomp>.<listcomp>-   s9   ø€ ÐXÐXÐXÈˆZˆZ˜˜qœ	 6¨!¤9¨f°Q¬i¸À¼ÑCÔCÐXÐXÐXr   )Úrange)r#   r%   r   r   r   r   Ún_br&   s    @€€€€€€r   r'   z(_pairwise_similarity.<locals>.<listcomp>,   sU   øø€ ð 	
ð 	
ð 	
àð YÐXÐXÐXÐXÐXÐXÐXÐXÍUÐSVÉZÌZÐXÑXÔXð	
ð 	
ð 	
r   )r   ÚshapeÚnpÚarrayr(   )
r   r   r&   Ún_aÚresultr   r   r   r   r)   s
     `  @@@@@r   Ú_pairwise_similarityr/   !   s•   øøøøøø€ õ &=¸QÀÑ%BÔ%BÑ"€FˆF�F˜FØ
Œ,�qŒ/€CØ
Œ,�qŒ/€CÝŒXð	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
ð 	
å˜3‘Z”Zð	
ñ 	
ô 	
ñô €Fð €Mr   Újaccard)r   r   r&   T)Úprefer_skip_nested_validation)r&   c                ó0  — |dk    rt           }t          | ||¦  «        }t          d|z
  ¦  «        \  }}t          | d         ¦  «        }t          |d         ¦  «        }t	          |||f                              ¦   «         t          ||¦  «        z  ¦  «        S )aX  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')
    1.0
    r0   g      ð?r   )r   r/   r   ÚlenÚfloatr   Úmax)r   r   r&   ÚmatrixÚrow_indicesÚcol_indicesr-   r)   s           r   r   r   4   s‹   € ðp �YÒÐÝˆ
Ý! ! Q¨
Ñ3Ô3€FÝ4°S¸6±\ÑBÔBÑ€K�Ý
ˆa�Œd‰)Œ)€CÝ
ˆa�Œd‰)Œ)€CÝ�˜ [Ð0Ô1×5Ò5Ñ7Ô7½#¸cÀ3¹-¼-ÑGÑHÔHÐHr   )Únumpyr+   Úscipy.optimizer   Úsklearn.utils._param_validationr   r   Úsklearn.utils.validationr   r   Ú__all__r   r   r/   ÚtupleÚcallabler   r"   r   r   ú<module>r@      s  ðð Ð Ð Ð Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0à GÐ GÐ GÐ GÐ GÐ GÐ GÐ GØ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IàÐ
€ð*ð *ð *ð;ð ;ð ;ðð ð ð& €àˆWØˆWØ  ¨Y¨KÑ!8Ô!8Ð9ðð ð
 #'ðñ ô ð )2ð 6Ið 6Ið 6Ið 6Iñô ð6Ið 6Ið 6Ir   