ó
    Ñ]j˜  ã            
       óÂ  • S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKrSSKJr  SS	KJrJrJrJrJrJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-  SS
K.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7  SSK8J9r9  SSK:J;r;J<r<J=r=  SSK>J?r?  SSK@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrH  SSKIJJrJ  S rKS rL " S S5      rM " S S\D5      rN " S S\N5      rO\=" S\P\QS/0SS9S 5       rR " S S\D5      rSS rTS rU\=" \Q/\V\W\<" 1 S k5      /S!/S".SS9S#SS$.S% j5       rX\X" \5      rY\X" \(5      rZ\X" \S&S'9r[\X" \$S&S'9r\\X" \%S&S'9r]\X" \ S&S'9r^\X" \!S&S'9r_\X" \&S&S'9r`\X" \+S&S'9ra\X" \,S&S'9rb\X" \#S&S'9rc\X" \"S&S'9rd\X" \5      re\X" \S(S)9rf\X" \S(S)9rg\X" \5      rh\X" \5      ri\X" \5      rjS* rkS+ rl\X" \k5      rm\X" \lS&S'9rn\X" \-SS,S-9ro\X" \*SS,S-9rp\X" \S,S)9rq\X" \*S(S.S/9rr\X" \*S(S.S0S19rs\X" \*S(S2S/9rt\X" \*S(S2S0S19ru\X" \S&S(S-9rv\X" \S&S(S-9rw\X" \S&S(S-9rx\X" \05      ry\X" \65      rz\X" \35      r{\X" \15      r|\X" \75      r}\X" \45      r~\X" \/5      r\X" \55      r€\X" \25      r�\‚" Sj0 S3\Y_S4\Z_S5\[_S6\j_S7\`_S8\^_S9\__S:\\_S;\]_S<\a_S=\b_S>\c_S?\d_S@\e_SA\g_SB\f_SC\h_SD\o_SE\p_SF\t_SG\r_SH\u_SI\s_SJ\i_SK\q_SL\v_SM\w_SN\m_SO\n_SP\y_SQ\z_SR\{_SS\|_ST\}_SU\~_SV\_SW\€_SX\�_6rƒSY r„SZ\'4S[\)4S\\4S]\44 H7  u  r…r†\X" \†S^S_9\ƒ\…'   S` H!  r‡SaGR                  \…\‡5      r‰\X" \†S\‡Sb9\ƒ\‰'   M#     M9     \=" \;" Sc5      S/\<" \Š" \„" 5       5      5      \Q\V\Š\W\‚S/S!/S!/Sd.SS9SkS&SSe.Sf jj5       r‹Sg rŒ " Sh Si\N5      r�g)laH  
The :mod:`sklearn.metrics.scorer` submodule implements a flexible
interface for model selection and evaluation using
arbitrary score functions.

A scorer object is a callable that can be passed to
:class:`~sklearn.model_selection.GridSearchCV` or
:func:`sklearn.model_selection.cross_val_score` as the ``scoring``
parameter, to specify how a model should be evaluated.

The signature of the call is ``(estimator, X, y)`` where ``estimator``
is the model to be evaluated, ``X`` is the test data and ``y`` is the
ground truth labeling (or ``None`` in the case of unsupervised models).
é    N)ÚCounter)Úpartial)Ú	signature)ÚIntegral)Ú
format_exc)Úis_regressor)Úaccuracy_scoreÚaverage_precision_scoreÚbalanced_accuracy_scoreÚbrier_score_lossÚclass_likelihood_ratiosÚd2_absolute_error_scoreÚd2_brier_scoreÚd2_log_loss_scoreÚexplained_variance_scoreÚf1_scoreÚjaccard_scoreÚlog_lossÚmatthews_corrcoefÚ	max_errorÚmean_absolute_errorÚmean_absolute_percentage_errorÚmean_gamma_devianceÚmean_poisson_devianceÚmean_squared_errorÚmean_squared_log_errorÚmedian_absolute_errorÚprecision_scoreÚr2_scoreÚrecall_scoreÚroc_auc_scoreÚroot_mean_squared_errorÚroot_mean_squared_log_errorÚtop_k_accuracy_score)	Úadjusted_mutual_info_scoreÚadjusted_rand_scoreÚcompleteness_scoreÚfowlkes_mallows_scoreÚhomogeneity_scoreÚmutual_info_scoreÚnormalized_mutual_info_scoreÚ
rand_scoreÚv_measure_score)ÚBunch)Ú
HasMethodsÚ
StrOptionsÚvalidate_params©Ú_get_response_values)ÚMetadataRequestÚMetadataRouterÚMethodMappingÚ_MetadataRequesterÚ_raise_for_paramsÚ_routing_enabledÚget_routing_for_objectÚprocess_routing)Ú_check_response_methodc                 óR   • U b	  X ;   a  X   $ [        U/UQ7SU0UD6u  pVU b  XPU'   U$ )z/Call estimator with method and args and kwargs.Úresponse_methodr2   )ÚcacheÚ	estimatorr>   ÚargsÚkwargsÚresultÚ_s          ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sklearn/metrics/_scorer.pyÚ_cached_callrF   [   sR   € àÑ˜_Ó5ØÑ%Ð%ä$ØðØòØ*9ðØ=Cñ�I€Fð ÑØ!'ˆoÑà€Mó    c                 óZ   • [        U [        5      (       a  [        U 5      $ U R                  $ )z6Returns the name of the function or repr of a partial.)Ú
isinstancer   ÚreprÚ__name__)Úfuncs    rE   Ú_get_func_repr_or_namerM   j   s#   € ä�$œ× Ñ Ü�D‹zÐà�=‰=ÐrG   c                   óD   • \ rS rSrSrSS.S jrS rS rS rS	 r	S
 r
Srg)Ú_MultimetricScorerér   an  Callable for multimetric scoring used to avoid repeated calls
to `predict_proba`, `predict`, and `decision_function`.

`_MultimetricScorer` will return a dictionary of scores corresponding to
the scorers in the dictionary. Note that `_MultimetricScorer` can be
created with a dictionary with one key  (i.e. only one actual scorer).

Parameters
----------
scorers : dict
    Dictionary mapping names to callable scorers.

raise_exc : bool, default=True
    Whether to raise the exception in `__call__` or not. If set to `False`
    a formatted string of the exception details is passed as result of
    the failing scorer.
T)Ú	raise_excc                ó   • Xl         X l        g ©N)Ú_scorersÚ
_raise_exc)ÚselfÚscorersrQ   s      rE   Ú__init__Ú_MultimetricScorer.__init__…   s   € ØŒØ#�rG   c                 ó¶  • 0 nU R                  U5      (       a  0 OSn[        [        U5      n[        5       (       a  [	        U S40 UD6nO»UR                  5        VV	s0 s H  u  p‰US:w  d  M  X‰_M     n
nn	[        S0 U R                   Vs0 s H  o»[        U
R                  5       S9_M     snD6nSU;   aN  U R                  R                  5        H0  u  p¼UR                  5       (       d  M  US   X{   R                  S'   M2     U R                  R                  5        Ht  u  p¼ [        U[        5      (       a0  UR                  " Xa/UQ70 UR                  U5      R                  D6nO%U" U/UQ70 UR                  U5      R                  D6nXÔU'   Mv     U$ s  sn	nf s  snf ! [         a*  nU R                   (       a  Ue[#        5       XK'    SnAM´  SnAff = f)z!Evaluate predicted target values.NÚscoreÚsample_weight©r[   © )Ú
_use_cacher   rF   r9   r;   Úitemsr.   rT   ÚcopyÚ_accept_sample_weightr[   rI   Ú_BaseScorerÚ_scoreÚgetÚ	ExceptionrU   r   )rV   r@   rA   rB   Úscoresr?   Úcached_callÚrouted_paramsÚargÚvalueÚcommon_kwargsÚnameÚscorerr[   Úes                  rE   Ú__call__Ú_MultimetricScorer.__call__‰   s¿  € àˆØ—o‘o i×0Ñ0‘°dˆÜœl¨EÓ2ˆä×ÑÜ+¨D°'ÑD¸VÑD‰Mð .4¯\©\¬^ôÚ-;™z˜s¸sÀoÑ?U“
�’
©^ð ñ ô "ñ ØGKÇ}Â}ÓUÂ}¸tœ ]×%7Ñ%7Ó%9Ñ:Ò:Á}ÑUñˆMð  &Ó(Ø$(§M¡M×$7Ñ$7Ö$9‘L�DØ×3Ñ3×5Ó5ØEKØ+ñF˜Ñ+×1Ñ1°/ÓBñ %:ð !ŸM™M×/Ñ/Ö1‰LˆDð0Ü˜f¤k×2Ñ2Ø"ŸMšMØ#ðØ15òØ9F×9JÑ9JÈ4Ó9P×9VÑ9Vñ‘Eñ # 9ÐU¨tÒU°}×7HÑ7HÈÓ7N×7TÑ7TÑU�EØ$�t“ñ 2ð ˆùó7ùò Vøô$ ó 0Ø—?—?Ø�Gä#-£<�F—Lûð	0ús+   ÁFÁ-FÂ!FÄ%A.F$Æ$
GÆ.GÇGc                 óx   • SR                  U R                   Vs/ s H	  nSU S3PM     sn5      nSU S3$ s  snf )Nú, Ú"zMultiMetricScorer(Ú))ÚjoinrT   )rV   ÚsrW   s      rE   Ú__repr__Ú_MultimetricScorer.__repr__³   s?   € Ø—)‘)¨t¯}ª}Ó=ª}¨!˜q   1›X©}Ñ=Ó>ˆØ# G 9¨AÐ.Ð.ùò >s   š7c                 óV   • [        S U R                  R                  5        5       5      $ )Nc              3   ó@   #   • U  H  oR                  5       v •  M     g 7frS   )rb   )Ú.0rn   s     rE   Ú	<genexpr>Ú;_MultimetricScorer._accept_sample_weight.<locals>.<genexpr>¹   s   é € ÐWÒ@V°f×/Ñ/×1Ð1Ò@Vùs   ‚)ÚanyrT   Úvalues©rV   s    rE   rb   Ú(_MultimetricScorer._accept_sample_weight·   s    € äÑWÀÇÁ×@TÑ@TÔ@VÓWÓWÐWrG   c           	      ó^  • [        U R                  5      S:X  a  g[        U R                  R                  5        Vs/ s H9  n[	        U[
        5      (       d  M  [        XR                  5      R                  PM;     sn5      n[        S UR                  5        5       5      (       a  ggs  snf )zeReturn True if using a cache is beneficial, thus when a response method will
be called several time.
é   Fc              3   ó*   #   • U  H	  oS :„  v •  M     g7f)r„   Nr^   )r|   Úvals     rE   r}   Ú0_MultimetricScorer._use_cache.<locals>.<genexpr>É   s   é € Ð3Ò"2˜3�QŽwÒ"2ùs   ‚T)
ÚlenrT   r   r€   rI   rc   r<   Ú_response_methodrK   r   )rV   r@   rn   Úcounters       rE   r_   Ú_MultimetricScorer._use_cache»   s’   € ô ˆt�}‰}Ó Ó"Øäð #Ÿm™m×2Ñ2Ô4óâ4�FÜ˜f¤k×2ó TÔ& y×2IÑ2IÓJ×SÔSÙ4ñó
ˆô Ñ3 '§.¡.Ô"2Ó3×3Ñ3ð àùòs   ¼B*Á#B*c           
      ó|   • [        U S9R                  " S0 U R                  DS[        5       R                  SSS90D6$ )a  Get metadata routing of this object.

Please check :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

.. versionadded:: 1.3

Returns
-------
routing : MetadataRouter
    A :class:`~utils.metadata_routing.MetadataRouter` encapsulating
    routing information.
©ÚownerÚmethod_mappingr[   )ÚcallerÚcalleer^   )r5   ÚaddrT   r6   r�   s    rE   Úget_metadata_routingÚ'_MultimetricScorer.get_metadata_routingÐ   sB   € ô  DÑ)×-Ò-ñ 
Ø�m‰mñ
ä(›?×.Ñ.°gÀgÐ.ÐNò
ð 	
rG   )rU   rT   N)rK   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rX   rp   rx   rb   r_   r“   Ú__static_attributes__r^   rG   rE   rO   rO   r   s,   † ñð$ .2õ $ò(òT/òXòõ*
rG   rO   c                   óP   • \ rS rSrSrSS jrS rS rS rS r	SS	 jr
S
 rS rSrg)rc   éä   a
  Base scorer that is used as `scorer(estimator, X, y_true)`.

Parameters
----------
score_func : callable
    The score function to use. It will be called as
    `score_func(y_true, y_pred, **kwargs)`.

sign : int
    Either 1 or -1 to returns the score with `sign * score_func(estimator, X, y)`.
    Thus, `sign` defined if higher scores are better or worse.

kwargs : dict
    Additional parameters to pass to the score function.

response_method : str
    The method to call on the estimator to get the response values.
c                 ó4   • Xl         X l        X0l        X@l        g rS   )Ú_score_funcÚ_signÚ_kwargsr‰   )rV   Ú
score_funcÚsignrB   r>   s        rE   rX   Ú_BaseScorer.__init__ø   s   € Ø%ÔØŒ
ØŒØ /ÕrG   c                 óª   • SU R                   ;   a  U R                   S   $ [        U R                  5      R                  nSU;   a  US   R                  $ g )NÚ	pos_label)rŸ   r   r�   Ú
parametersÚdefault)rV   Úscore_func_paramss     rE   Ú_get_pos_labelÚ_BaseScorer._get_pos_labelþ   sQ   € Ø˜$Ÿ,™,Ó&Ø—<‘< Ñ,Ð,Ü% d×&6Ñ&6Ó7×BÑBÐØÐ+Ó+Ø$ [Ñ1×9Ñ9Ð9ØrG   c                 óF   • S[        U R                  5      R                  ;   $ ©Nr\   )r   r�   r¥   r�   s    rE   rb   Ú!_BaseScorer._accept_sample_weight  s   € à¤)¨D×,<Ñ,<Ó"=×"HÑ"HÑHÐHrG   c           
      ó  • U R                   S:”  a  SOSnSU R                  < 3nSR                  U R                  R	                  5        VVs/ s H  u  p4SU SU 3PM     snn5      nS[        U R                  5       U U U S3$ s  snnf )	Nr   Ú z, greater_is_better=Falsez, response_method=rs   Ú=zmake_scorer(ru   )rž   r‰   rv   rŸ   r`   rM   r�   )rV   Úsign_stringÚresponse_method_stringÚkÚvÚkwargs_strings         rE   rx   Ú_BaseScorer.__repr__
  s˜   € Ø ŸJ™J¨›N‘bÐ0KˆØ#5°d×6KÑ6KÑ5NÐ!OÐØŸ™¸$¿,¹,×:LÑ:LÔ:NÔ OÒ:N±$°! 2 a S¨¨!¨£Ñ:NÒ OÓPˆð Ô1°$×2BÑ2BÓCÐDÀ[ÀMØ%Ð& } o°Qð8ð	
ùó !Ps   ÁB
c                 ó   • [        U 5      $ rS   ©rJ   r�   s    rE   Ú_routing_reprÚ_BaseScorer._routing_repr  ó   € Ü�D‹zÐrG   Nc                 óš   • [        XPS5        [        R                  " U5      nUb  XFS'   U R                  " [	        [
        S5      XU40 UD6$ )a   Evaluate predicted target values for X relative to y_true.

Parameters
----------
estimator : object
    Trained estimator to use for scoring. Must have a predict_proba
    method; the output of that is used to compute the score.

X : {array-like, sparse matrix}
    Test data that will be fed to estimator.predict.

y_true : array-like
    Gold standard target values for X.

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

**kwargs : dict
    Other parameters passed to the scorer. Refer to
    :func:`set_score_request` for more details.

    Only available if `enable_metadata_routing=True`. See the
    :ref:`User Guide <metadata_routing>`.

    .. versionadded:: 1.3

Returns
-------
score : float
    Score function applied to prediction of estimator on X.
Nr\   )r8   ra   Údeepcopyrd   r   rF   )rV   r@   ÚXÚy_truer\   rB   rŸ   s          rE   rp   Ú_BaseScorer.__call__  sK   € ô@ 	˜&¨Ô-ä—-’- Ó'ˆØÑ$Ø'4�OÑ$à�{Š{œ7¤<°Ó6¸	ÀfÑXÐPWÑXÐXrG   c                 ó  • U R                   c
  [        5       O"[        U R                   R                  5       5      nUR                  UR                  5       5      nU(       a!  [        R
                  " U SU 3[        5        gg)z»Warn if there is any overlap between ``self._kwargs`` and ``kwargs``.

This method is intended to be used to check for overlap between
``self._kwargs`` and ``kwargs`` passed as metadata.
Nz Overlapping parameters are: )rŸ   ÚsetÚkeysÚintersectionÚwarningsÚwarnÚUserWarning)rV   ÚmessagerB   rŸ   Úoverlaps        rE   Ú_warn_overlapÚ_BaseScorer._warn_overlap?  sc   € ð  Ÿ<™<Ñ/”#”%´S¸¿¹×9JÑ9JÓ9LÓ5MˆØ×&Ñ& v§{¡{£}Ó5ˆÞÜ�MŠMØ�)Ð8¸¸	ÐBÄKõð rG   c                 óî   • [        5       (       d  [        S5      eU R                  SUS9  [        U S9U l        UR                  5        H(  u  p#U R                  R                  R                  X#S9  M*     U $ )a/  Set requested parameters by the scorer.

Please see :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

.. versionadded:: 1.3

Parameters
----------
kwargs : dict
    Arguments should be of the form ``param_name=alias``, and `alias`
    can be one of ``{True, False, None, str}``.
z‰This method is only available when metadata routing is enabled. You can enable it using sklearn.set_config(enable_metadata_routing=True).zäYou are setting metadata request for parameters which are already set as kwargs for this metric. These set values will be overridden by passed metadata if provided. Please pass them either as metadata or kwargs to `make_scorer`.©rÇ   rB   r�   )ÚparamÚalias)r9   ÚRuntimeErrorrÉ   r4   Ú_metadata_requestr`   r[   Úadd_request)rV   rB   rÍ   rÎ   s       rE   Úset_score_requestÚ_BaseScorer.set_score_requestL  s‚   € ô  ×!Ñ!ÜðEóð ð 	×Ñð:ð
 ð 	ñ 	
ô "1°tÑ!<ˆÔØ"ŸL™LžN‰LˆEØ×"Ñ"×(Ñ(×4Ñ4¸5Ð4ÓNñ +àˆrG   )rŸ   rÐ   r‰   r�   rž   )ÚpredictrS   )rK   r•   r–   r—   r˜   rX   r¨   rb   rx   r¸   rp   rÉ   rÒ   r™   r^   rG   rE   rc   rc   ä   s2   † ñô&0òòIò
òô&YòPõ!rG   rc   c                   ó   • \ rS rSrS rSrg)Ú_Scorerip  c                 ó  • U R                  SUS9  [        U5      (       a  SOU R                  5       n[        X R                  5      nU" U[        U5      UUS9n0 U R                  EUEn	U R                  U R                  " XH40 U	D6-  $ )aÛ  Evaluate the response method of `estimator` on `X` and `y_true`.

Parameters
----------
method_caller : callable
    Returns predictions given an estimator, method name, and other
    arguments, potentially caching results.

estimator : object
    Trained estimator to use for scoring.

X : {array-like, sparse matrix}
    Test data that will be fed to clf.decision_function or
    clf.predict_proba.

y_true : array-like
    Gold standard target values for X. These must be class labels,
    not decision function values.

**kwargs : dict
    Other parameters passed to the scorer. Refer to
    :func:`set_score_request` for more details.

Returns
-------
score : float
    Score function applied to prediction of estimator on X.
z¡There is an overlap between set kwargs of this scorer instance and passed metadata. Please pass them either as kwargs to `make_scorer` or metadata, but not both.rÌ   N©r¤   )	rÉ   r   r¨   r<   r‰   Ú_get_response_method_namerŸ   rž   r�   )
rV   Úmethod_callerr@   r½   r¾   rB   r¤   r>   Úy_predÚscoring_kwargss
             rE   rd   Ú_Scorer._scoreq  sœ   € ð: 	×Ñð.ð ð 	ñ 	
ô )¨×3Ñ3‘D¸×9LÑ9LÓ9Nˆ	Ü0°×<QÑ<QÓRˆÙØÜ% oÓ6ØØñ	
ˆð 4˜DŸL™LÐ3¨FÐ3ˆØ�z‰z˜D×,Ò,¨VÑN¸~ÑNÑNÐNrG   r^   N)rK   r•   r–   r—   rd   r™   r^   rG   rE   rÖ   rÖ   p  s   † õ0OrG   rÖ   ÚscoringT)Úprefer_skip_nested_validationc                 ó¬   • [        U [        5      (       a    [        R                  " [        U    5      nU$ U nU$ ! [
         a    [        SU -  5      ef = f)a�  Get a scorer from string.

Read more in the :ref:`User Guide <scoring_parameter>`.
:func:`~sklearn.metrics.get_scorer_names` can be used to retrieve the names
of all available scorers.

Parameters
----------
scoring : str, callable or None
    Scoring method as string. If callable it is returned as is.
    If None, returns None.

Returns
-------
scorer : callable
    The scorer.

Notes
-----
When passed a string, this function always returns a copy of the scorer
object. Calling `get_scorer` twice for the same scorer results in two
separate scorer objects.

Examples
--------
>>> import numpy as np
>>> from sklearn.dummy import DummyClassifier
>>> from sklearn.metrics import get_scorer
>>> X = np.reshape([0, 1, -1, -0.5, 2], (-1, 1))
>>> y = np.array([0, 1, 1, 0, 1])
>>> classifier = DummyClassifier(strategy="constant", constant=0).fit(X, y)
>>> accuracy = get_scorer("accuracy")
>>> accuracy(classifier, X, y)
0.4
z]%r is not a valid scoring value. Use sklearn.metrics.get_scorer_names() to get valid options.)rI   Ústrra   r¼   Ú_SCORERSÚKeyErrorÚ
ValueError)rÞ   rn   s     rE   Ú
get_scorerrå   ¤  sh   € ôT �'œ3×Ñð	Ü—]’]¤8¨GÑ#4Ó5ˆFð €Mð ˆØ€Møô ó 	Üð(à*1ñ2óð ð	ús	   —: ºAc                   ó8   • \ rS rSrS rS rS rS rS rS r	Sr
g	)
Ú_PassthroughScoreriÜ  c                 ó   • Xl         g rS   ©Ú
_estimator)rV   r@   s     rE   rX   Ú_PassthroughScorer.__init__à  s   € Ø#�rG   c                 ó&   • UR                   " U0 UD6$ )z!Method that wraps estimator.scorer]   )rV   r@   rA   rB   s       rE   rp   Ú_PassthroughScorer.__call__ã  s   € à�Š Ð/¨Ñ/Ð/rG   c                 óF   • [        U R                  5      R                   S3$ )Nz.score)Útyperê   rK   r�   s    rE   rx   Ú_PassthroughScorer.__repr__ç  s   € Ü�t—‘Ó'×0Ñ0Ð1°Ð8Ð8rG   c                 ó   • [        U 5      $ rS   r·   r�   s    rE   r¸   Ú _PassthroughScorer._routing_reprê  rº   rG   c                 óZ   • S[        U R                  R                  5      R                  ;   $ r«   )r   rê   r[   r¥   r�   s    rE   rb   Ú(_PassthroughScorer._accept_sample_weightí  s"   € à¤)¨D¯O©O×,AÑ,AÓ"B×"MÑ"MÑMÐMrG   c                 ó,   • [        U R                  5      $ )a  Get requested data properties.

Please check :ref:`User Guide <metadata_routing>` on how the routing
mechanism works.

.. versionadded:: 1.3

Returns
-------
routing : MetadataRouter
    A :class:`~utils.metadata_routing.MetadataRouter` encapsulating
    routing information.
)r:   rê   r�   s    rE   r“   Ú'_PassthroughScorer.get_metadata_routingñ  s   € ô & d§o¡oÓ6Ð6rG   ré   N)rK   r•   r–   r—   rX   rp   rx   r¸   rb   r“   r™   r^   rG   rE   rç   rç   Ü  s!   † ò$ò0ò9òòNõ7rG   rç   c           
      ó`  • SU< S3n[        U[        [        [        45      (       aÂ  Sn [        U5      n[        U5      [        U5      :w  a  [        U SU< 35      e[        U5      S:”  ak  [        S U 5       5      (       d9  [        S U 5       5      (       a  [        U S	U< 35      e[        U S
U< 35      eU Vs0 s H  of[        XS9_M     nnU$ [        U SU< 35      e[        U[        5      (       a}  [        U5      n[        S U 5       5      (       d  [        SU< 35      e[        U5      S:X  a  [        SU< 35      eUR                  5        VVs0 s H  u  p†U[        XS9_M     nnnU$ [        U5      e! [         a  n[        U5      UeSnAff = fs  snf s  snnf )aÍ  Check the scoring parameter in cases when multiple metrics are allowed.

In addition, multimetric scoring leverages a caching mechanism to not call the same
estimator response method multiple times. Hence, the scorer is modified to only use
a single response method given a list of response methods and the estimator.

Parameters
----------
estimator : sklearn estimator instance
    The estimator for which the scoring will be applied.

scoring : list, tuple or dict
    Strategy to evaluate the performance of the cross-validated model on
    the test set.

    The possibilities are:

    - a list or tuple of unique strings;
    - a callable returning a dictionary where they keys are the metric
      names and the values are the metric scores;
    - a dictionary with metric names as keys and callables a values.

    See :ref:`multimetric_grid_search` for an example.

Returns
-------
scorers_dict : dict
    A dict mapping each scorer name to its validated scorer.
zscoring is invalid (got zh). Refer to the scoring glossary for details: https://scikit-learn.org/stable/glossary.html#term-scoringzFThe list/tuple elements must be unique strings of predefined scorers. Nz2 Duplicate elements were found in the given list. r   c              3   óB   #   • U  H  n[        U[        5      v •  M     g 7frS   ©rI   rá   ©r|   r²   s     rE   r}   Ú-_check_multimetric_scoring.<locals>.<genexpr>5  s   é € Ð8²4¨a”z !¤S×)Ð)²4ùó   ‚c              3   ó8   #   • U  H  n[        U5      v •  M     g 7frS   )Úcallablerú   s     rE   r}   rû   6  s   é € Ð1ªD q”x —{�{ªDùs   ‚zi One or more of the elements were callables. Use a dict of score name mapped to the scorer callable. Got z4 Non-string types were found in the given list. Got ©rÞ   z Empty list was given. c              3   óB   #   • U  H  n[        U[        5      v •  M     g 7frS   rù   rú   s     rE   r}   rû   J  s   é € Ð4ªt¨!”:˜a¤×%Ð%ªtùrü   zCNon-string types were found in the keys of the given dict. scoring=zAn empty dict was passed. )rI   ÚlistÚtuplerÁ   Ú	TypeErrorrä   rˆ   Úallr   Úcheck_scoringÚdictr`   )	r@   rÞ   Úerr_msg_genericÚerr_msgrÂ   ro   rn   rW   Úkeys	            rE   Ú_check_multimetric_scoringr
    s  € ð> # 7¡+ð .Eð 	Eð ô �'œD¤%¬Ð-×.Ñ.àTð 	ð	-Ü�w“<ˆDô ˆt‹9œ˜G›Ó$ÜØ�)ð $Ø$+¡;ð0óð ô �‹Y˜‹]ÜÑ8±4Ó8×8Ñ8ÜÑ1©DÓ1×1Ñ1Ü$Ø"˜)ð $ð  '™kð+óð ô %Ø"˜)ð $2Ø29±ð>óð ñ
 PWóÚOVÀVœ iÑ@Ò@Éwð ð ð, €Nô%  ˜yÐ(?À¹{ÐKÓLÐLä	�GœT×	"Ñ	"Ü�7‹|ˆÜÑ4©tÓ4×4Ñ4Üð+Ø+2©+ð7óð ô ˆt‹9˜‹>ÜÐ9¸'¹ÐEÓFÐFð  'Ÿ}™}œô
â.‘�ð ”˜yÑ9Ò9Ù.ð 	ñ 
ð €Nô ˜Ó)Ð)øôU ó 	-Ü˜WÓ%¨1Ð,ûð	-üò,ùó
s#   «F ÃF%Å!F*Æ
F"ÆFÆF"c                 óf   •  U R                   $ ! [         a    [        U R                  5      s $ f = frS   )rK   ÚAttributeErrorrÙ   rL   ©r>   s    rE   rÙ   rÙ   [  s3   € ð?Ø×'Ñ'Ð'øÜó ?Ü(¨×)=Ñ)=Ó>Ò>ð?ús   ‚ Ž0¯0>   rÔ   Úpredict_probaÚdecision_functionÚboolean)r    r>   Úgreater_is_betterrÔ   )r>   r  c                ó0   • U(       a  SOSn[        XX15      $ )a  Make a scorer from a performance metric or loss function.

A scorer is a wrapper around an arbitrary metric or loss function that is called
with the signature `scorer(estimator, X, y_true, **kwargs)`.

It is accepted in all scikit-learn estimators or functions allowing a `scoring`
parameter.

The parameter `response_method` allows to specify which method of the estimator
should be used to feed the scoring/loss function.

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

Parameters
----------
score_func : callable
    Score function (or loss function) with signature
    ``score_func(y, y_pred, **kwargs)``.

response_method : {"predict_proba", "decision_function", "predict"} or             list/tuple of such str, default="predict"

    Specifies the response method to use get prediction from an estimator
    (i.e. :term:`predict_proba`, :term:`decision_function` or
    :term:`predict`). Possible choices are:

    - if `str`, it corresponds to the name to the method to return;
    - if a list or tuple of `str`, it provides the method names in order of
      preference. The method returned corresponds to the first method in
      the list and which is implemented by `estimator`.

    .. versionadded:: 1.4

greater_is_better : bool, default=True
    Whether `score_func` is a score function (default), meaning high is
    good, or a loss function, meaning low is good. In the latter case, the
    scorer object will sign-flip the outcome of the `score_func`.

**kwargs : additional arguments
    Additional parameters to be passed to `score_func`.

Returns
-------
scorer : callable
    Callable object that returns a scalar score; greater is better.

Examples
--------
>>> from sklearn.metrics import fbeta_score, make_scorer
>>> ftwo_scorer = make_scorer(fbeta_score, beta=2)
>>> ftwo_scorer
make_scorer(fbeta_score, response_method='predict', beta=2)
>>> from sklearn.model_selection import GridSearchCV
>>> from sklearn.svm import LinearSVC
>>> grid = GridSearchCV(LinearSVC(), param_grid={'C': [1, 10]},
...                     scoring=ftwo_scorer)
r„   éÿÿÿÿ)rÖ   )r    r>   r  rB   r¡   s        rE   Úmake_scorerr  b  s   € öP "‰1 r€Dä�: VÓ=Ð=rG   F)r  r  r  c                 ó   • [        XSS9S   $ )Nç      ð?©Úreplace_undefined_byr   ©r   ©r¾   rÛ   s     rE   Úpositive_likelihood_ratior  ×  ó   € Ü" 6ÈÑLÈQÑOÐOrG   c                 ó   • [        XSS9S   $ )Nr  r  r„   r  r  s     rE   Únegative_likelihood_ratior  Û  r  rG   )r  r  )r  r>   Úovo)r>   Úmulti_classÚweighted)r>   r   ÚaverageÚovrÚexplained_varianceÚr2Úneg_max_errorr   Úneg_median_absolute_errorÚneg_mean_absolute_errorÚ"neg_mean_absolute_percentage_errorÚneg_mean_squared_errorÚneg_mean_squared_log_errorÚneg_root_mean_squared_errorÚneg_root_mean_squared_log_errorÚneg_mean_poisson_devianceÚneg_mean_gamma_deviancer   r   r   ÚaccuracyÚtop_k_accuracyÚroc_aucÚroc_auc_ovrÚroc_auc_ovoÚroc_auc_ovr_weightedÚroc_auc_ovo_weightedÚbalanced_accuracyÚaverage_precisionÚneg_log_lossÚneg_brier_scorer  Úneg_negative_likelihood_ratior&   r,   r)   r'   r-   r*   r%   r+   r(   c                  ó<   • [        [        R                  5       5      $ )aÐ  Get the names of all available scorers.

These names can be passed to :func:`~sklearn.metrics.get_scorer` to
retrieve the scorer object.

Returns
-------
list of str
    Names of all available scorers.

Examples
--------
>>> from sklearn.metrics import get_scorer_names
>>> all_scorers = get_scorer_names()
>>> type(all_scorers)
<class 'list'>
>>> all_scorers[:3]
['accuracy', 'adjusted_mutual_info_score', 'adjusted_rand_score']
>>> "roc_auc" in all_scorers
True
)Úsortedrâ   rÂ   r^   rG   rE   Úget_scorer_namesr>  I  s   € ô, ”(—-‘-“/Ó"Ð"rG   Ú	precisionÚrecallÚf1ÚjaccardÚbinary)r"  )ÚmacroÚmicroÚsamplesr!  z{0}_{1})r¤   r"  Úfit)r@   rÞ   Ú
allow_nonerQ   )rH  rQ   c                ó.  • [        U[        5      (       a  [        U5      $ [        U5      (       ay  [	        USS5      n[        US5      (       aP  UR                  S5      (       a:  UR                  S5      (       d$  UR                  S5      (       d  [        SU-  5      e[        U5      $ [        U[        [        [        [        45      (       a  [        XS9n[        XSS	9$ Uc2  [        U S
5      (       a  [        U 5      $ U(       a  g[        SU -  5      eg)aq
  Determine scorer from user options.

A TypeError will be thrown if the estimator cannot be scored.

Parameters
----------
estimator : estimator object implementing 'fit' or None, default=None
    The object to use to fit the data. If `None`, then this function may error
    depending on `allow_none`.

scoring : str, callable, list, tuple, set, or dict, default=None
    Scorer to use. If `scoring` represents a single score, one can use:

    - a single string (see :ref:`scoring_string_names`);
    - a callable (see :ref:`scoring_callable`) that returns a single value;
    - `None`, the `estimator`'s
      :ref:`default evaluation criterion <scoring_api_overview>` is used.

    If `scoring` represents multiple scores, one can use:

    - a list, tuple or set of unique strings;
    - a callable returning a dictionary where the keys are the metric names and the
      values are the metric scorers;
    - a dictionary with metric names as keys and callables a values. The callables
      need to have the signature `callable(estimator, X, y)`.

allow_none : bool, default=False
    Whether to return None or raise an error if no `scoring` is specified and the
    estimator has no `score` method.

raise_exc : bool, default=True
    Whether to raise an exception (if a subset of the scorers in multimetric scoring
    fails) or to return an error code.

    - If set to `True`, raises the failing scorer's exception.
    - If set to `False`, a formatted string of the exception details is passed as
      result of the failing scorer(s).

    This applies if `scoring` is list, tuple, set, or dict. Ignored if `scoring` is
    a str or a callable.

    .. versionadded:: 1.6

Returns
-------
scoring : callable
    A scorer callable object / function with signature ``scorer(estimator, X, y)``.

Examples
--------
>>> from sklearn.datasets import load_iris
>>> from sklearn.metrics import check_scoring
>>> from sklearn.tree import DecisionTreeClassifier
>>> X, y = load_iris(return_X_y=True)
>>> classifier = DecisionTreeClassifier(max_depth=2).fit(X, y)
>>> scorer = check_scoring(classifier, scoring='accuracy')
>>> scorer(classifier, X, y)
0.96...

>>> from sklearn.metrics import make_scorer, accuracy_score, mean_squared_log_error
>>> X, y = load_iris(return_X_y=True)
>>> y *= -1
>>> clf = DecisionTreeClassifier().fit(X, y)
>>> scoring = {
...     "accuracy": make_scorer(accuracy_score),
...     "mean_squared_log_error": make_scorer(mean_squared_log_error),
... }
>>> scoring_call = check_scoring(estimator=clf, scoring=scoring, raise_exc=False)
>>> scores = scoring_call(clf, X, y)
>>> scores
{'accuracy': 1.0, 'mean_squared_log_error': 'Traceback ...'}
r•   NÚ
startswithzsklearn.metrics.zsklearn.metrics._scorerzsklearn.metrics.tests.zÀscoring value %r looks like it is a metric function rather than a scorer. A scorer should require an estimator as its first parameter. Please use `make_scorer` to convert a metric to a scorer.rÿ   )rW   rQ   r[   ziIf no scoring is specified, the estimator passed should have a 'score' method. The estimator %r does not.)rI   rá   rå   rþ   ÚgetattrÚhasattrrJ  rä   r  r  rÁ   r  r
  rO   rç   r  )r@   rÞ   rH  rQ   ÚmodulerW   s         rE   r  r  n  s  € ôt �'œ3×ÑÜ˜'Ó"Ð"Ü�×Ñä˜ ,°Ó5ˆä�F˜L×)Ñ)Ø×!Ñ!Ð"4×5Ñ5Ø×%Ñ%Ð&?×@Ñ@Ø×%Ñ%Ð&>×?Ñ?äðð ")ñ	)óð ô ˜'Ó"Ð"Ü�'œD¤%¬¬dÐ3×4Ñ4Ü,¨YÑHˆÜ!¨'ÑGÐGØ�Ü�9˜g×&Ñ&Ü% iÓ0Ð0ÞØäðDØFOñPóð ð rG   c                 ó  • Uc  [         R                  " SS/5      nOM[         R                  " X#:H  5      S   n[         R                  " X#:g  5      S   n[         R                  " Xe/5      nX$X:¬  R                  [        5            $ )z;Threshold `y_score` and return the associated class labels.r   r„   )ÚnpÚarrayÚflatnonzeroÚastypeÚint)Úy_scoreÚ	thresholdÚclassesr¤   Úmap_thresholded_score_to_labelÚpos_label_idxÚneg_label_idxs          rE   Ú!_threshold_scores_to_class_labelsrZ  ê  sv   € àÑÜ)+¯ª°1°a°&Ó)9Ñ&äŸš wÑ';Ó<¸QÑ?ˆÜŸš wÑ';Ó<¸QÑ?ˆÜ)+¯ª°=Ð2PÓ)QÐ&à°7Ñ3G×2OÑ2OÔPSÓ2TÑUÑVÐVrG   c                   óB   ^ • \ rS rSrSrU 4S jr\S 5       rS rSr	U =r
$ )Ú_CurveScoreriö  a^  Scorer taking a continuous response and output a score for each threshold.

Parameters
----------
score_func : callable
    The score function to use. It will be called as
    `score_func(y_true, y_pred, **kwargs)`.

sign : int
    Either 1 or -1 to returns the score with `sign * score_func(estimator, X, y)`.
    Thus, `sign` defined if higher scores are better or worse.

kwargs : dict
    Additional parameters to pass to the score function.

thresholds : int or array-like
    Related to the number of decision thresholds for which we want to compute the
    score. If an integer, it will be used to generate `thresholds` thresholds
    uniformly distributed between the minimum and maximum predicted scores. If an
    array-like, it will be used as the thresholds.

response_method : str
    The method to call on the estimator to get the response values.
c                 ó2   >• [         TU ]  UUUUS9  X@l        g )N)r    r¡   rB   r>   )ÚsuperrX   Ú_thresholds)rV   r    r¡   rB   Ú
thresholdsr>   Ú	__class__s         €rE   rX   Ú_CurveScorer.__init__  s)   ø€ Ü‰ÑØ!ØØØ+ð	 	ñ 	
ð &ÕrG   c                 ó€   • U " UR                   UR                  UUUR                  S9nUR                  5       Ul        U$ )z0Create a continuous scorer from a normal scorer.)r    r¡   r>   r`  rB   )r�   rž   rŸ   Ú_get_metadata_requestrÐ   )Úclsrn   r>   r`  Úinstances        rE   Úfrom_scorerÚ_CurveScorer.from_scorer  sC   € ñ Ø×)Ñ)Ø—‘Ø+Ø!Ø—>‘>ñ
ˆð &,×%AÑ%AÓ%CˆÔ"ØˆrG   c                 ó>  • U R                  5       nU" X R                  X6S9n0 U R                  EUEn[        U R                  [
        5      (       aK  [        R                  " [        R                  " U5      [        R                  " U5      U R                  5      n	O [        R                  " U R                  5      n	U	 V
s/ s H9  n
U R                  U R                  " U[        XzUR                  U5      40 UD6-  PM;     nn
[        R                  " U5      U	4$ s  sn
f )a,  Evaluate predicted target values for X relative to y_true.

Parameters
----------
method_caller : callable
    Returns predictions given an estimator, method name, and other
    arguments, potentially caching results.

estimator : object
    Trained estimator to use for scoring.

X : {array-like, sparse matrix} of shape (n_samples, n_features)
    Test data that will be fed to estimator.predict.

y_true : array-like of shape (n_samples,)
    Gold standard target values for X.

**kwargs : dict
    Other parameters passed to the scorer. Refer to
    :func:`set_score_request` for more details.

Returns
-------
scores : ndarray of shape (thresholds,)
    The scores associated to each threshold.

potential_thresholds : ndarray of shape (thresholds,)
    The potential thresholds used to compute the scores.
rØ   )r¨   r‰   rŸ   rI   r_  r   rO  ÚlinspaceÚminÚmaxÚasarrayrž   r�   rZ  Úclasses_rP  )rV   rÚ   r@   r½   r¾   rB   r¤   rT  rÜ   Úpotential_thresholdsÚthÚscore_thresholdss               rE   rd   Ú_CurveScorer._score'  s  € ð< ×'Ñ'Ó)ˆ	ÙØ×,Ñ,¨añ
ˆð 4˜DŸL™LÐ3¨FÐ3ˆÜ�d×&Ñ&¬×1Ñ1Ü#%§;¢;Ü—’�w“¤§¢¨£°$×2BÑ2Bó$Ñ ô $&§:¢:¨d×.>Ñ.>Ó#?Ð ñ +ó

ò +�ð �J‰JØ×ÒØÜ1Ø ×!3Ñ!3°Yóñð
 !ñôñ +ð 	ð 

ô �xŠxÐ(Ó)Ð+?Ð?Ð?ùò

s   Ã A D)r_  )rK   r•   r–   r—   r˜   rX   Úclassmethodrg  rd   r™   Ú__classcell__)ra  s   @rE   r\  r\  ö  s-   ø† ñõ2&ð ñó ð÷5@ð 5@rG   r\  r^   )NN)Žr˜   ra   rÄ   Úcollectionsr   Ú	functoolsr   Úinspectr   Únumbersr   Ú	tracebackr   ÚnumpyrO  Úsklearn.baser   Úsklearn.metricsr	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   Úsklearn.metrics.clusterr%   r&   r'   r(   r)   r*   r+   r,   r-   Úsklearn.utilsr.   Úsklearn.utils._param_validationr/   r0   r1   Úsklearn.utils._responser3   Úsklearn.utils.metadata_routingr4   r5   r6   r7   r8   r9   r:   r;   Úsklearn.utils.validationr<   rF   rM   rO   rc   rÖ   rá   rþ   rå   rç   r
  rÙ   r  r  r  Úexplained_variance_scorerÚ	r2_scorerÚneg_max_error_scorerÚneg_mean_squared_error_scorerÚ!neg_mean_squared_log_error_scorerÚneg_mean_absolute_error_scorerÚ)neg_mean_absolute_percentage_error_scorerÚ neg_median_absolute_error_scorerÚ"neg_root_mean_squared_error_scorerÚ&neg_root_mean_squared_log_error_scorerÚ neg_mean_poisson_deviance_scorerÚneg_mean_gamma_deviance_scorerÚd2_absolute_error_scorerÚd2_brier_score_scorerÚd2_log_loss_scorerÚaccuracy_scorerÚbalanced_accuracy_scorerÚmatthews_corrcoef_scorerr  r  Ú positive_likelihood_ratio_scorerÚ$neg_negative_likelihood_ratio_scorerÚtop_k_accuracy_scorerÚroc_auc_scorerÚaverage_precision_scorerÚroc_auc_ovo_scorerÚroc_auc_ovo_weighted_scorerÚroc_auc_ovr_scorerÚroc_auc_ovr_weighted_scorerÚneg_log_loss_scorerÚneg_brier_score_scorerÚbrier_score_loss_scorerÚadjusted_rand_scorerÚrand_scorerÚhomogeneity_scorerÚcompleteness_scorerÚv_measure_scorerÚmutual_info_scorerÚadjusted_mutual_info_scorerÚnormalized_mutual_info_scorerÚfowlkes_mallows_scorerr  râ   r>  rm   Úmetricr"  ÚformatÚqualified_namerÁ   r  rZ  r\  r^   rG   rE   Ú<module>r­     sb  ðñó$ Û Ý Ý Ý Ý Ý  ã å %÷÷ ÷ ÷ ÷ ÷ ÷ ó ÷<
÷ 
õ 
õ  ÷ñ õ
 9÷	÷ 	ó 	õ <òò÷o
ñ o
ôdIÐ$ô IôX1Oˆkô 1Oñh à�C˜ 4Ð(ðð #'ñ	ñ/óð/ôd#7Ð+ô #7òLVòr?ñ à�jàØÙÒHÓIð
ð
 (˜[ñð #'ñð $-Àô>>óð>>ñD (Ð(@ÓAÐ Ù˜Ó!€	Ù" 9ÀÑFÐ Ù +Ð,>ÐRWÑ XÐ Ù$/Ø¨eñ%Ð !ñ "-Ø¨5ñ"Ð ñ -8Ø"°eñ-Ð )ñ $/Ø¨Uñ$Ð  ñ &1Ø¨uñ&Ð "ñ *5Ø°5ñ*Ð &ñ $/Ø¨Uñ$Ð  ñ "-Ø¨5ñ"Ð ñ 'Ð'>Ó?Ð Ù# NÀOÑTÐ Ù Ð!2ÀOÑTÐ ñ ˜nÓ-€Ù&Ð'>Ó?Ð Ù&Ð'8Ó9Ð òPòPñ $/Ð/HÓ#IÐ  Ù'2Ø°ñ(Ð $ñ
 $ØØØ:ñÐ ñ
 ØØØ:ñ€ñ
 'ØØ:ñÐ ñ !Ø ?ÀñÐ ñ *ØØ#ØØñ	Ð ñ !Ø ?ÀñÐ ñ *ØØ#ØØñ	Ð ñ "Ø °ñÐ ñ %Ø¨¸ñÐ ñ &Ø¨¸ñÐ ñ #Ð#6Ó7Ð Ù˜*Ó%€Ù Ð!2Ó3Ð Ù!Ð"4Ó5Ð Ù˜Ó/Ð Ù Ð!2Ó3Ð Ù)Ð*DÓEÐ Ù +Ð,HÓ IÐ Ù$Ð%:Ó;Ð ñ ò (Ù0ð(áð(ñ 'ð(ñ /ð	(ñ
 ?ð(ñ ;ð(ñ (Qð(ñ 9ð(ñ  Að(ñ !Cð(ñ %Kð(ñ ?ð(ñ ;ð(ñ 5ð(ñ )ð(ñ  )ð!(ñ" ð#(ñ$ )ð%(ñ& ð'(ñ( #ð)(ñ* #ð+(ñ, 5ð-(ñ. 5ð/(ñ0 /ð1(ñ2 /ð3(ñ4 %ð5(ñ6 +ð7(ñ8 ?ð9(ñ: #Gð;(ñ> -ð?(ñ@ ðA(ñB )ðC(ñD +ðE(ñF %ðG(ñH )ðI(ñJ  ;ðK(ñL "?ðM(ñN 1ðO(€òV#ð4 �/Ð"Øˆ|ÐØ	ˆ8ÐØ�Ðó	�L€Dˆ&ñ ! °Ñ:€HˆT�NÛ<ˆØ"×)Ò)¨$°Ó8ˆÙ#.¨vÀÈwÑ#Wˆ�Ó ó =ññ á  Ó'¨Ð.á‘sÑ+Ó-Ó.Ó/ØØØØØØð
ð !�kØ�[ñð #'ñð"h¸eÈtõ hó#ð"hòV	Wôf@�;õ f@rG   