
    Ug                     p    d dl ZddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ  G d d	          Zd
 Zd ZdS )    N   )check_consistent_length)check_matplotlib_support)_get_response_values_binary)type_of_target)_check_pos_label_consistencyc                   `    e Zd ZdZddddZeddddd            Zeddddd	            ZdS )
"_BinaryClassifierCurveDisplayMixinzMixin class to be used in Displays requiring a binary classifier.

    The aim of this class is to centralize some validations regarding the estimator and
    the target and gather the response of the estimator.
    N)axnamec                    t          | j        j         d           dd lm} ||                                \  }}|| j        n|}||j        |fS )Nz.plotr   )r   	__class____name__matplotlib.pyplotpyplotsubplotsestimator_namefigure)selfr   r   plt_s        V/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/sklearn/utils/_plotting.py_validate_plot_paramsz8_BinaryClassifierCurveDisplayMixin._validate_plot_params   sf     DN$;!B!B!BCCC'''''':LLNNEAr&*lt""29d""    auto)response_method	pos_labelr   c                    t          | j         d           ||j        j        n|}t          ||||          \  }}|||fS )Nz.from_estimator)r   r   )r   r   r   r   )cls	estimatorXyr   r   r   y_preds           r   !_validate_and_get_response_valueszD_BinaryClassifierCurveDisplayMixin._validate_and_get_response_values   se     	!CL!A!A!ABBB/3|y"++7+	
 
 
	 y$&&r   )sample_weightr   r   c                    t          | j         d           t          |          dk    r t          dt          |           d          t	          |||           t          ||          }||nd}||fS )Nz.from_predictionsbinaryz The target y is not binary. Got z type of target.
Classifier)r   r   r   
ValueErrorr   r   )r   y_truer#   r%   r   r   s         r   !_validate_from_predictions_paramszD_BinaryClassifierCurveDisplayMixin._validate_from_predictions_params,   s     	!CL!C!C!CDDD&!!X-->&3I3I     
 	 >>>0FCC	'tt\$r   )r   
__module____qualname____doc__r   classmethodr$   r+    r   r   r
   r
   
   s          +/T # # # # # 174d' ' ' ' ['  .2d    [  r   r
   c                 2   | | S ||rdndS t          |          r|j        n|} |r&|                     d          r| dd         } n(d|  } n"|                     d          rd| dd          } |                     dd          } |                                 S )	a  Validate the `score_name` parameter.

    If `score_name` is provided, we just return it as-is.
    If `score_name` is `None`, we use `Score` if `negate_score` is `False` and
    `Negative score` otherwise.
    If `score_name` is a string or a callable, we infer the name. We replace `_` by
    spaces and capitalize the first letter. We remove `neg_` and replace it by
    `"Negative"` if `negate_score` is `False` or just remove it otherwise.
    NzNegative scoreScoreneg_   z	Negative r    )callabler   
startswithreplace
capitalize)
score_namescoringnegate_scores      r   _validate_score_namer=   @   s     	#/<W<)1'):):GW%%
 	6$$V,, 6'^

555

""6** 	65Z^55J''S11
$$&&&r   c                     t          j        t          j        |                     }|                                |                                z  S )a   Compute the ratio between the largest and smallest inter-point distances.

    A value larger than 5 typically indicates that the parameter range would
    better be displayed with a log scale while a linear scale would be more
    suitable otherwise.
    )npdiffsortmaxmin)datar@   s     r   _interval_max_min_ratiorE   [   s6     7274==!!D88::

""r   )numpyr?    r   _optional_dependenciesr   	_responser   
multiclassr   
validationr   r
   r=   rE   r0   r   r   <module>rL      s        % % % % % % < < < < < < 2 2 2 2 2 2 & & & & & & 4 4 4 4 4 43 3 3 3 3 3 3 3l' ' '6# # # # #r   