Ë
    êÿæi$Q  ã                   óÊ   — d Z ddlZddlmZ ddlmZ ddlZddlm	Z	 ddl
mZ ddlmZmZ ddlmZ dd	lmZmZmZ dd
„Zdd„ZeeedœZd„ Zd„ Zd„ Zd„ Zdd„Zdd„Zdd„Zd„ Zy)zAUtilities to handle multiclass/multioutput target in classifiers.é    N)ÚSequence)Úchain)Úissparse)Úget_namespace)Úattach_uniqueÚcached_unique)ÚVisibleDeprecationWarning)Ú_assert_all_finiteÚ_num_samplesÚcheck_arrayc                 óŒ   — t        | |¬«      \  }}t        | d«      s|rt        |j                  | «      |¬«      S t	        | «      S )N©ÚxpÚ	__array__)r   Úhasattrr   ÚasarrayÚset©Úyr   Úis_array_api_compliants      úm/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/sklearn/utils/multiclass.pyÚ_unique_multiclassr      s?   € Ü!.¨q°RÔ!8Ñ€BÐÜˆq�+ÔÑ"8Ü˜RŸZ™Z¨›]¨rÔ2Ð2ä�1‹vˆó    c                 óz   — t        | |¬«      \  }}|j                  t        | dg d¢¬«      j                  d   «      S )Nr   r   ©ÚcsrÚcscÚcoo)Ú
input_nameÚaccept_sparseé   )r   Úaranger   Úshape)r   r   Ú_s      r   Ú_unique_indicatorr%      s<   € Ü˜! Ô#�E€BˆØ�9‰9Ü�A #Ò5JÔK×QÑQÐRSÑTóð r   )ÚbinaryÚ
multiclassúmultilabel-indicatorc            	      ó  ‡‡— t        | ddiŽ} t        | Ž \  Š}t        | «      dk(  rt        d«      ‚t	        d„ | D «       «      }|ddhk(  rdh}t        |«      dkD  rt        d	|z  «      ‚|j                  «       }|d
k(  r)t        t	        d„ | D «       «      «      dkD  rt        d«      ‚t        j                  |d«      Š‰st        dt        | «      z  «      ‚|r8‰j                  | D �cg c]  } ‰|‰¬«      ‘Œ c}«      }‰j                  |«      S t	        t        j                  ˆˆfd„| D «       «      «      }t        t	        d„ |D «       «      «      dkD  rt        d«      ‚‰j                  t        |«      «      S c c}w )a�  Extract an ordered array of unique labels.

    We don't allow:
        - mix of multilabel and multiclass (single label) targets
        - mix of label indicator matrix and anything else,
          because there are no explicit labels)
        - mix of label indicator matrices of different sizes
        - mix of string and integer labels

    At the moment, we also don't allow "multiclass-multioutput" input type.

    Parameters
    ----------
    *ys : array-likes
        Label values.

    Returns
    -------
    out : ndarray of shape (n_unique_labels,)
        An ordered array of unique labels.

    Examples
    --------
    >>> from sklearn.utils.multiclass import unique_labels
    >>> unique_labels([3, 5, 5, 5, 7, 7])
    array([3, 5, 7])
    >>> unique_labels([1, 2, 3, 4], [2, 2, 3, 4])
    array([1, 2, 3, 4])
    >>> unique_labels([1, 2, 10], [5, 11])
    array([ 1,  2,  5, 10, 11])
    Úreturn_tupleTr   zNo argument has been passed.c              3   ó2   K  — | ]  }t        |«      –— Œ y ­w©N)Útype_of_target)Ú.0Úxs     r   Ú	<genexpr>z unique_labels.<locals>.<genexpr>O   s   è ø€ Ð1©b¨”> !×$©bùs   ‚r&   r'   r!   z'Mix type of y not allowed, got types %sr(   c              3   óT   K  — | ]   }t        |g d ¢¬«      j                  d   –— Œ" y­w)r   )r    r!   N)r   r#   )r.   r   s     r   r0   z unique_labels.<locals>.<genexpr>\   s)   è ø€ ð ÙVXÐQR”˜AÒ-BÔC×IÑIÈ!ÕLÑVXùs   ‚&(zCMulti-label binary indicator input with different numbers of labelsNzUnknown label type: %sr   c              3   ó@   •K  — | ]  }d „  ‰|‰¬«      D «       –— Œ y­w)c              3   ó    K  — | ]  }|–— Œ y ­wr,   © )r.   Úis     r   r0   z*unique_labels.<locals>.<genexpr>.<genexpr>q   s   è ø€ ÐAÑ(@ 1œQÑ(@ùs   ‚r   Nr4   )r.   r   Ú_unique_labelsr   s     €€r   r0   z unique_labels.<locals>.<genexpr>q   s   øè ø€ ÐNÉ2ÀaÑA©°q¸RÕ(@×AÉ2ùs   ƒc              3   ó<   K  — | ]  }t        |t        «      –— Œ y ­wr,   )Ú
isinstanceÚstr)r.   Úlabels     r   r0   z unique_labels.<locals>.<genexpr>t   s   è ø€ Ð=±9¨%Œz˜%¤×%±9ùs   ‚z,Mix of label input types (string and number))r   r   ÚlenÚ
ValueErrorr   ÚpopÚ_FN_UNIQUE_LABELSÚgetÚreprÚconcatÚunique_valuesr   Úfrom_iterabler   Úsorted)	Úysr   Úys_typesÚ
label_typer   Ú	unique_ysÚ	ys_labelsr6   r   s	          @@r   Úunique_labelsrJ   )   s�  ù€ ô@ 
˜Ð	.¨Ñ	.€BÜ!.°Ð!3Ñ€BÐÜ
ˆ2ƒw�!‚|ÜÐ7Ó8Ð8ô Ñ1©bÓ1Ó1€HØ�H˜lÐ+Ò+Ø �>ˆä
ˆ8ƒ}�qÒÜÐBÀXÑMÓNÐNà—‘“€Jð 	Ð,Ò,ÜÜñ ÙVXóó ó
ð
 òô ØQó
ð 	
ô
 '×*Ñ*¨:°tÓ<€NÙÜÐ1´D¸³HÑ<Ó=Ð=áà—I‘IÁÓDÁ¸A™~¨a°BÖ7ÀÑDÓEˆ	Ø×Ñ 	Ó*Ð*äÜ×ÑÔNÉ2ÓNÓNó€Iô Œ3Ñ=±9Ó=Ó=Ó>ÀÒBÜÐGÓHÐHà�:‰:”f˜YÓ'Ó(Ð(ùò Es   Ã(E<c           
      óü   — t        | «      \  }}|j                  | j                  d«      xrQ t        |j	                  |j                  |j                  | |j                  «      | j                  «      | k(  «      «      S )Núreal floating)r   ÚisdtypeÚdtypeÚboolÚallÚastypeÚint64r   s      r   Ú_is_integral_floatrS   z   sd   € Ü!.¨qÓ!1Ñ€BÐØ�:‰:�a—g‘g˜Ó/ò ´DØ
�‰ˆr�y‰y˜"Ÿ)™) A r§x¡xÓ0°1·7±7Ó;¸qÑ@ÓAó5ð r   c                 óü  — t        | «      \  }}t        | d«      st        | t        «      s|rWt	        dddddd¬«      }t        j                  «       5  t        j                  dt        «       	 t        | fddi|¤Ž} ddd«       t        | d
«      r!| j                  dk(  r| j                  d   dkD  syt!        | «      r | j"                  dv r| j%                  «       } |j'                  | j(                  «      }t+        | j(                  «      dk(  xsM |j,                  dk(  xs |j,                  dk(  xr d|v xr% | j.                  j0                  dv xs t3        |«      S t5        | |¬«      }|j                  d   dk  xr) |j7                  | j.                  d«      xs t3        |«      S # t        t        f$ r8}t        |«      j                  d	«      r‚ t        | fdt        i|¤Ž} Y d}~�Œmd}~ww xY w# 1 sw Y   �ŒwxY w)a}  Check if ``y`` is in a multilabel format.

    Parameters
    ----------
    y : ndarray of shape (n_samples,)
        Target values.

    Returns
    -------
    out : bool
        Return ``True``, if ``y`` is in a multilabel format, else ``False``.

    Examples
    --------
    >>> import numpy as np
    >>> from sklearn.utils.multiclass import is_multilabel
    >>> is_multilabel([0, 1, 0, 1])
    False
    >>> is_multilabel([[1], [0, 2], []])
    False
    >>> is_multilabel(np.array([[1, 0], [0, 0]]))
    True
    >>> is_multilabel(np.array([[1], [0], [0]]))
    False
    >>> is_multilabel(np.array([[1, 0, 0]]))
    True
    r   TFr   ©r    Úallow_ndÚensure_all_finiteÚ	ensure_2dÚensure_min_samplesÚensure_min_featuresÚerrorrN   NúComplex data not supportedr#   é   r!   )ÚdokÚlilÚbiur   é   )rO   zsigned integerzunsigned integer)r   r   r8   r   ÚdictÚwarningsÚcatch_warningsÚsimplefilterr	   r   r<   r9   Ú
startswithÚobjectÚndimr#   r   ÚformatÚtocsrrB   Údatar;   ÚsizerN   ÚkindrS   r   rM   )r   r   r   Úcheck_y_kwargsÚeÚlabelss         r   Úis_multilabelrq   �   sÓ  € ô8 "/¨qÓ!1Ñ€BÐÜˆq�+Ô¤*¨Q´Ô"9Ñ=Sô ØØØ#ØØ Ø !ô
ˆô ×$Ñ$Õ&Ü×!Ñ! 'Ô+DÔEðCÜ Ñ@¨Ð@°Ñ@�÷ 'ô �A�wÔ A§F¡F¨a¢K°A·G±G¸A±JÀ²NØä�„{Ø�8‰8�~Ñ%Ø—‘“	ˆAØ×!Ñ! !§&¡&Ó)ˆÜ�1—6‘6‹{˜aÑò 
Ø�[‰[˜AÑÒG 6§;¡;°!Ñ#3Ò"F¸!¸v¸+ò FØ—‘—‘ Ð&ÒDÔ*<¸VÓ*Dð	
ô
 ˜q RÔ(ˆà�|‰|˜A‰ Ñ"ò 
Ø�J‰J�q—w‘wÐ NÓOò *Ü! &Ó)ð	
øô- .¬zÐ:ò CÜ�q“6×$Ñ$Ð%AÔBØô   ÑB¬ÐB°>ÑB–ûðCú÷	 'Ñ&ús0   ÁG1Á.F'Æ'G.Æ6-G)Ç#G1Ç)G.Ç.G1Ç1G;c                 óø   — t        | d¬«      }|dvrt        d|› d�«      ‚d|v rVt        | «      }|dkD  rEt        | «      j                  d   t        d	|z  «      kD  rt        j                  d
t        d¬«       yyyy)aA  Ensure that target y is of a non-regression type.

    Only the following target types (as defined in type_of_target) are allowed:
        'binary', 'multiclass', 'multiclass-multioutput',
        'multilabel-indicator', 'multilabel-sequences'

    Parameters
    ----------
    y : array-like
        Target values.
    r   ©r   )r&   r'   zmulticlass-multioutputr(   zmultilabel-sequenceszUnknown label type: zy. Maybe you are trying to fit a classifier, which expects discrete classes on a regression target with continuous values.r'   é   r   g      à?z’The number of unique classes is greater than 50% of the number of samples. `y` could represent a regression problem, not a classification problem.r]   )Ú
stacklevelN)	r-   r<   r   r   r#   Úroundrc   ÚwarnÚUserWarning)r   Úy_typeÚ	n_sampless      r   Úcheck_classification_targetsr{   É   s�   € ô ˜A¨#Ô.€FØð ñ ô Ø" 6 (ð +8ð 8ó
ð 	
ð �vÑÜ  “Oˆ	Ø�rŠ>œm¨AÓ.×4Ñ4°QÑ7¼%ÀÀiÁÓ:PÒPä�M‰Mð*ô Øöð Qˆ>ð r   c                 óÂ  ‡ ‡‡— t        ‰ «      \  }}ˆˆˆ fd„}t        ‰ t        «      xs t        ‰ «      xs t	        ‰ d«      xr t        ‰ t
        «       xs |}|st        d‰ z  «      ‚‰ j                  j                  dv }|rt        d«      ‚t        ‰ «      ryt        ddddd	d	¬
«      }t        j                  «       5  t        j                  dt        «       t        ‰ «      s	 t        ‰ fddi|¤ŽŠ ddd«       	 t        ‰ «      r
‰ d	gdd…f   n‰ d	   }
t        |
t$        «      rt'        d«      ‚t	        |
d«      s+t        |
t        «      rt        |
t
        «      st        d«      ‚‰ j*                  dvr |«       S t-        ‰ j.                  «      s‰ j*                  dk(  ry |«       S t        ‰ «      s7‰ j0                  t"        k(  r$t        ‰ j2                  d	   t
        «      s |«       S ‰ j*                  dk(  r‰ j.                  d   dkD  rd}nd}|j5                  ‰ j0                  d«      rut        ‰ «      r‰ j6                  n‰ }|j9                  ||j:                  «      }|j=                  ||j9                  |‰ j0                  «      k7  «      rt?        |‰¬«       d|z   S t        
«      r|
j6                  }
tA        ‰ «      j.                  d	   dkD  s‰ j*                  dk(  rtC        |
«      dkD  rd|z   S y# t        t        f$ r8}	t        |	«      j!                  d«      r‚ t        ‰ fdt"        i|¤ŽŠ Y d}	~	�ŒFd}	~	ww xY w# 1 sw Y   �ŒPxY w# t(        $ r Y �Œòw xY w)aÊ
  Determine the type of data indicated by the target.

    Note that this type is the most specific type that can be inferred.
    For example:

    * ``binary`` is more specific but compatible with ``multiclass``.
    * ``multiclass`` of integers is more specific but compatible with ``continuous``.
    * ``multilabel-indicator`` is more specific but compatible with
      ``multiclass-multioutput``.

    Parameters
    ----------
    y : {array-like, sparse matrix}
        Target values. If a sparse matrix, `y` is expected to be a
        CSR/CSC matrix.

    input_name : str, default=""
        The data name used to construct the error message.

        .. versionadded:: 1.1.0

    raise_unknown : bool, default=False
        If `True`, raise an error when the type of target returned by
        :func:`~sklearn.utils.multiclass.type_of_target` is `"unknown"`.

        .. versionadded:: 1.6

    Returns
    -------
    target_type : str
        One of:

        * 'continuous': `y` is an array-like of floats that are not all
          integers, and is 1d or a column vector.
        * 'continuous-multioutput': `y` is a 2d array of floats that are
          not all integers, and both dimensions are of size > 1.
        * 'binary': `y` contains <= 2 discrete values and is 1d or a column
          vector.
        * 'multiclass': `y` contains more than two discrete values, is not a
          sequence of sequences, and is 1d or a column vector.
        * 'multiclass-multioutput': `y` is a 2d array that contains more
          than two discrete values, is not a sequence of sequences, and both
          dimensions are of size > 1.
        * 'multilabel-indicator': `y` is a label indicator matrix, an array
          of two dimensions with at least two columns, and at most 2 unique
          values.
        * 'unknown': `y` is array-like but none of the above, such as a 3d
          array, sequence of sequences, or an array of non-sequence objects.

    Examples
    --------
    >>> from sklearn.utils.multiclass import type_of_target
    >>> import numpy as np
    >>> type_of_target([0.1, 0.6])
    'continuous'
    >>> type_of_target([1, -1, -1, 1])
    'binary'
    >>> type_of_target(['a', 'b', 'a'])
    'binary'
    >>> type_of_target([1.0, 2.0])
    'binary'
    >>> type_of_target([1, 0, 2])
    'multiclass'
    >>> type_of_target([1.0, 0.0, 3.0])
    'multiclass'
    >>> type_of_target(['a', 'b', 'c'])
    'multiclass'
    >>> type_of_target(np.array([[1, 2], [3, 1]]))
    'multiclass-multioutput'
    >>> type_of_target([[1, 2]])
    'multilabel-indicator'
    >>> type_of_target(np.array([[1.5, 2.0], [3.0, 1.6]]))
    'continuous-multioutput'
    >>> type_of_target(np.array([[0, 1], [1, 1]]))
    'multilabel-indicator'
    c                  ó8   •— ‰r‰r‰nd} t        d| › d‰›�«      ‚y)zdDepending on the value of raise_unknown, either raise an error or return
        'unknown'.
        rk   zUnknown label type for z: Úunknown)r<   )Úinputr   Úraise_unknownr   s    €€€r   Ú_raise_or_returnz(type_of_target.<locals>._raise_or_return?  s-   ø€ ñ Ù",‘J°&ˆEÜÐ6°u°g¸RÀ¸uÐEÓFÐFàr   r   z:Expected array-like (array or non-string sequence), got %r)ÚSparseSeriesÚSparseArrayz1y cannot be class 'SparseSeries' or 'SparseArray'r(   TFr   rU   r[   rN   Nr\   zkSupport for labels represented as bytes is not supported. Convert the labels to a string or integer format.zÝYou appear to be using a legacy multi-label data representation. Sequence of sequences are no longer supported; use a binary array or sparse matrix instead - the MultiLabelBinarizer transformer can convert to this format.)r!   r]   r!   r&   r]   z-multioutputÚ rL   rs   Ú
continuousr'   )"r   r8   r   r   r   r9   r<   Ú	__class__Ú__name__rq   rb   rc   rd   re   r	   r   rf   rg   ÚbytesÚ	TypeErrorÚ
IndexErrorrh   Úminr#   rN   ÚflatrM   rk   rQ   rR   Úanyr
   r   r;   )r   r   r€   r   r   r�   ÚvalidÚsparse_pandasrn   ro   Úfirst_row_or_valÚsuffixrk   Úintegral_datas   ```           r   r-   r-   ð   s0  ú€ ôZ "/¨qÓ!1Ñ€BÐöô 
�A”xÓ	 Ò	J¤H¨Q£KÒ	J´7¸1¸kÓ3Jò 	#Ü˜1œcÓ"Ð"ò ð 
 ð 
ñ
 ÜØHÈ1ÑLó
ð 	
ð —K‘K×(Ñ(Ð,KÐK€MÙÜÐLÓMÐMä�QÔØ%ô ØØØØØØô€Nô 
×	 Ñ	 Õ	"Ü×Ñ˜gÔ'@ÔAÜ˜Œ{ðCÜ Ñ@¨Ð@°Ñ@�÷	 
#ðÜ(0°¬˜1˜a˜S¢!˜Vš9¸¸1¹ÐäÐ&¬Ô.Üð<óð ô Ð(¨+Ô6ÜÐ+¬XÔ6ÜÐ/´Ô5äð;óð ð 	‡v�v�VÑáÓ!Ð!Üˆq�w‰wŒ<à�6‰6�QŠ;àáÓ!Ð!Ü�AŒ;˜1Ÿ7™7¤fÒ,´ZÀÇÁÀqÁ	Ì3Ô5OáÓ!Ð!ð 	‡v�v�‚{�q—w‘w˜q‘z A’~Ø‰àˆð 
‡z�z�!—'‘'˜?Ô+ä! !œˆq�vŠv¨!ˆØŸ	™	 $¨¯©Ó1ˆð �6‰6�$˜"Ÿ)™) M°1·7±7Ó;Ñ;Ô<Ü˜t°
Õ;Ø &Ñ(Ð(ô Ð Ô!Ø+×0Ñ0ÐÜ�QÓ×Ñ˜aÑ  1Ò$¨¯©°1ª¼Ð=MÓ9NÐQRÒ9Rà˜fÑ$Ð$àøôQ .¬zÐ:ò CÜ�q“6×$Ñ$Ð%AÔBØô   ÑB¬ÐB°>ÑB–ûðCú÷ 
#Ñ	"ûôD ò ÚðúsC   Ã&MÃ(K:Ã?A,M Ë:MÌ	-L<Ì6MÌ<MÍMÍMÍ	MÍMc                 ó  — t        | dd«      €|€t        d«      ‚|�ct        | dd«      �Et        j                  | j                  t        |«      «      st        d|›d| j                  ›�«      ‚yt        |«      | _        yy)a"  Private helper function for factorizing common classes param logic.

    Estimators that implement the ``partial_fit`` API need to be provided with
    the list of possible classes at the first call to partial_fit.

    Subsequent calls to partial_fit should check that ``classes`` is still
    consistent with a previous value of ``clf.classes_`` when provided.

    This function returns True if it detects that this was the first call to
    ``partial_fit`` on ``clf``. In that case the ``classes_`` attribute is also
    set on ``clf``.

    Úclasses_Nz8classes must be passed on the first call to partial_fit.z	`classes=z7` is not the same as on last call to partial_fit, was: TF)Úgetattrr<   ÚnpÚarray_equalr”   rJ   )ÚclfÚclassess     r   Ú_check_partial_fit_first_callrš   ·  s†   € ô ˆs�J Ó%Ð-°'°/ÜÐSÓTÐTà	Ð	Ü�3˜
 DÓ)Ð5Ü—>‘> #§,¡,´¸gÓ0FÔGÝ â18¸#¿,º,ðHóð ð ô )¨Ó1ˆCŒLØð r   c                 ó,  — g }g }g }| j                   \  }}|�t        j                  |«      }t        | «      �r¿| j	                  «       } t        j
                  | j                  «      }t        |«      D �]€  }| j                  | j                  |   | j                  |dz       }	|�1||	   }
t        j                  |«      t        j                  |
«      z
  }nd}
| j                   d   ||   z
  }t        j                  | j                  | j                  |   | j                  |dz       d¬«      \  }}t        j                  ||
¬«      }d|v r||dk(  xx   |z  cc<   d|vrC||   | j                   d   k  r.t        j                  |dd«      }t        j                  |d|«      }|j                  |«       |j                  |j                   d   «       |j                  ||j                  «       z  «       �Œƒ n™t        |«      D ]‹  }t        j                  | dd…|f   d¬«      \  }}|j                  |«       |j                  |j                   d   «       t        j                  ||¬«      }|j                  ||j                  «       z  «       Œ� |||fS )az  Compute class priors from multioutput-multiclass target data.

    Parameters
    ----------
    y : {array-like, sparse matrix} of size (n_samples, n_outputs)
        The labels for each example.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    Returns
    -------
    classes : list of size n_outputs of ndarray of size (n_classes,)
        List of classes for each column.

    n_classes : list of int of size n_outputs
        Number of classes in each column.

    class_prior : list of size n_outputs of ndarray of size (n_classes,)
        Class distribution of each column.
    Nr!   r   T)Úreturn_inverse)Úweights)r#   r–   r   r   ÚtocscÚdiffÚindptrÚrangeÚindicesÚsumÚuniquerk   ÚbincountÚinsertÚappend)r   Úsample_weightr™   Ú	n_classesÚclass_priorrz   Ú	n_outputsÚy_nnzÚkÚcol_nonzeroÚnz_samp_weightÚzeros_samp_weight_sumÚ	classes_kÚy_kÚclass_prior_ks                  r   Úclass_distributionr´   Ú  sG  € ð, €GØ€IØ€KàŸ7™7Ñ€IˆyØÐ ÜŸ
™
 =Ó1ˆä�…{Ø�G‰G‹IˆÜ—‘˜Ÿ™Ó!ˆä�y×!ˆAØŸ)™) A§H¡H¨Q¡K°!·(±(¸1¸q¹5±/ÐBˆKàÐ(Ø!.¨{Ñ!;�Ü(*¯©¨}Ó(=ÄÇÁÀ~Ó@VÑ(VÑ%à!%�Ø()¯©°©
°U¸1±XÑ(=Ð%äŸY™YØ—‘�q—x‘x ‘{ Q§X¡X¨a°!©e¡_Ð5Àdô‰NˆI�sô ŸK™K¨°^ÔDˆMð �I‰~Ø˜i¨1™nÓ-Ð1FÑFÓ-ð ˜	Ñ! e¨A¡h°·±¸±Ò&;ÜŸI™I i°°AÓ6�	Ü "§	¡	¨-¸Ð<QÓ R�à�N‰N˜9Ô%Ø×Ñ˜YŸ_™_¨QÑ/Ô0Ø×Ñ˜}¨}×/@Ñ/@Ó/BÑBÖCñ9 "ô< �yÖ!ˆAÜŸY™Y qª¨A¨¡w¸tÔD‰NˆI�sØ�N‰N˜9Ô%Ø×Ñ˜YŸ_™_¨QÑ/Ô0ÜŸK™K¨°]ÔCˆMØ×Ñ˜}¨}×/@Ñ/@Ó/BÑBÕCð "ð �Y Ð,Ð,r   c                 óÜ  — | j                   d   }t        j                  ||f«      }t        j                  ||f«      }d}t        |«      D ]}  }t        |dz   |«      D ]i  }|dd…|fxx   |dd…|f   z  cc<   |dd…|fxx   |dd…|f   z  cc<   || dd…|f   dk(  |fxx   dz  cc<   || dd…|f   dk(  |fxx   dz  cc<   |dz  }Œk Œ |dt        j                  |«      dz   z  z  }	||	z   S )ay  Compute a continuous, tie-breaking OvR decision function from OvO.

    It is important to include a continuous value, not only votes,
    to make computing AUC or calibration meaningful.

    Parameters
    ----------
    predictions : array-like of shape (n_samples, n_classifiers)
        Predicted classes for each binary classifier.

    confidences : array-like of shape (n_samples, n_classifiers)
        Decision functions or predicted probabilities for positive class
        for each binary classifier.

    n_classes : int
        Number of classes. n_classifiers must be
        ``n_classes * (n_classes - 1 ) / 2``.
    r   r!   Nra   )r#   r–   Úzerosr¡   Úabs)
ÚpredictionsÚconfidencesr©   rz   ÚvotesÚsum_of_confidencesr­   r5   ÚjÚtransformed_confidencess
             r   Ú_ovr_decision_functionr¾   $  s  € ð& ×!Ñ! !Ñ$€IÜ�H‰H�i Ð+Ó,€EÜŸ™ 9¨iÐ"8Ó9Ðà	€AÜ�9ÖˆÜ�q˜1‘u˜iÖ(ˆAØšq !˜tÓ$¨²A°q°DÑ(9Ñ9Ó$Øšq !˜tÓ$¨²A°q°DÑ(9Ñ9Ó$Ø�+ša ˜dÑ# qÑ(¨!Ð+Ó,°Ñ1Ó,Ø�+ša ˜dÑ# qÑ(¨!Ð+Ó,°Ñ1Ó,Ø�‰F‰Añ )ð ð 1Ø	ŒR�V‰VÐ&Ó'¨!Ñ+Ñ,ñÐð Ð*Ñ*Ð*r   r,   )r„   F) Ú__doc__rc   Úcollections.abcr   Ú	itertoolsr   Únumpyr–   Úscipy.sparser   Úsklearn.utils._array_apir   Úsklearn.utils._uniquer   r   Úsklearn.utils.fixesr	   Úsklearn.utils.validationr
   r   r   r   r%   r>   rJ   rS   rq   r{   r-   rš   r´   r¾   r4   r   r   Ú<module>rÈ      sw   ðÙ Gó
 Ý $Ý ã Ý !å 2ß >Ý 9ß RÑ Róóð !Ø$Ø-ñÐ òN)òbòE
òP$óNDóN óFG-óT*+r   