
    {Kg                     h    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y)    N   )check_consistent_length)check_matplotlib_support)_get_response_values_binary)type_of_target)_check_pos_label_consistencyc                   R    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y)
"_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                         \  }}|| j                  n|}||j                  |fS )Nz.plotr   )r   	__class____name__matplotlib.pyplotpyplotsubplotsestimator_namefigure)selfr   r   plt_s        [/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/sklearn/utils/_plotting.py_validate_plot_paramsz8_BinaryClassifierCurveDisplayMixin._validate_plot_params   sU     DNN$;$;#<E!BC':LLNEAr&*lt""299d""    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   sX     	!CLL>!AB/3|y""++7+	
	 y$&&r   )sample_weightr   r   c                    t        | j                   d       t        |      dk7  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,   sz     	!CLL>1B!CD&!X-2>&3I2J K  
 	 >0FC	't\$r   )r   
__module____qualname____doc__r   classmethodr$   r+    r   r   r
   r
   
   sI     +/T # 174d' '  .2d r   r
   c                     | | S ||rdS dS t        |      r|j                  n|} |r| j                  d      r| dd } nd|  } n| j                  d      rd| dd  } | j                  dd      } | j	                         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'):W%%
$$V,'^
(5
""6*$Z^$45J''S1
$$&&r   c                     t        j                  t        j                  |             }|j                         |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   [   s1     772774=!D88:
""r   )numpyr?    r   _optional_dependenciesr   	_responser   
multiclassr   
validationr   r
   r=   rE   r0   r   r   <module>rL      s,     % < 2 & 43 3l'6#r   