`L i <ddlZddlmZddlZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZmZGd d Zd Zd ZdZdZdZdZdZy)N)Mapping)check_consistent_length)check_matplotlib_support)_get_response_values_binary) parse_version)type_of_target)_check_pos_label_consistency _num_samplesceZdZdZddddZedddddZeddddd Zed Ze d Z e 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)axnamec t|jjdddlm}||j \}}|t |dt |dd}||j|fS)Nz.plotrestimator_namer)r __class____name__matplotlib.pyplotpyplotsubplotsgetattrfigure)selfrrplt_s ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/utils/_plotting.py_validate_plot_paramsz8_BinaryClassifierCurveDisplayMixin._validate_plot_paramssc DNN$;$;#!AB/3|y""++7  +   y$&&r) sample_weightr!rct|jdt|dk7rtdt|dt |||t ||}||nd}||fS)Nz.from_predictionsbinaryz The target y is not binary. Got  type of target. Classifier)rrr ValueErrorrr )r#y_truer'r)r!rs r!_validate_from_predictions_paramszD_BinaryClassifierCurveDisplayMixin._validate_from_predictions_params5sz !CLL>1B!CD & !X -2>&3I2JK   >0FC 't\$rct|jdddh}tfd|Dstd|dt dddt dd d}}t |||zk7rtd ||zd t |d t |d k7rtdt |dt||| t||}|S#t$r)} tt| jddd} ~ wwxYw)Nz.from_cv_resultsr$indicesc3&K|]}|v yw)N).0key cv_resultss r zV_BinaryClassifierCurveDisplayMixin._validate_from_cv_results_params..Us>3*$>szB`cv_results` does not contain one of the following required keys: zr. Set explicitly the parameters `return_estimator=True` and `return_indices=True` to the function`cross_validate`.trainrtestz=`X` does not contain the correct number of samples. Expected z, got .r+z"The target `y` is not binary. Got r,r/r&) rrallr.lenr r rr strreplace) r#r7r%r&r)r! required_keys train_size test_sizees ` r _validate_from_cv_results_paramszC_BinaryClassifierCurveDisplayMixin._validate_from_cv_results_paramsHsL !CLL>1A!BC$i0 > >>T /"$$   9%g.q1 2  9%f-a0 1 ?j94 4&236,q/9J!M  !  (4^A5F4GGWX  1m4 <4YBI   <SV^^Hc:; ; `curve_kwargs` must be None, a dictionary or a list of length z. Got: r;rzfTo avoid labeling individual curves that have the same appearance, `curve_kwargs` should be a list of z dictionaries. Alternatively, set `name` to `None` or a single string to label a single legend entry with mean ROC AUC score of all curves.Ng?z--blue)alpha linestylecolormeanrstdz +/- rFrGmetricrK)r.warningswarn FutureWarning isinstancelistr=r>rr rLextendzipappend enumerate_validate_style_kwargs)n_curvesr legend_metricrJ curve_kwargskwargsdefault_multi_curve_kwargslabelslabel_aggregaterHrIfold_idxrK curve_kwargs_s r_validate_curve_kwargsz9_BinaryClassifierCurveDisplayMixin._validate_curve_kwargsswJ F?   MMR  "L lD )c,.?8.KP*GL>4  tT "D Q|T266>Z@OO  dC 6D dD !c$i1n(?D$(Lv d lG ,(>H4L/2PV%W"  !| :;hF "t  ] "@RRf%tAw0BO U#/7&',}U7KD6QQR/SS$ (E-2Ft1L*MM$ MM?+tf1 .EE F36}X7NPT3U /#Z 6HH+Z9K $-V#4 % #GU#3\(5K L    s:G) r __module__ __qualname____doc__r classmethodr(r0rD staticmethodrLrir4rrr r s +/T #174d'' .2d$++Z  vvrr c||S||rdSdSt|r |jn|}|r|jdr|dd}nd|}n|jdrd|dd}|jdd}|j S) aValidate 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. NzNegative scoreScoreneg_z Negative r )callabler startswithr? capitalize) score_namescoring negate_scores r_validate_score_namerzs #/Check required and optional parameters are of the same length.rrz, NrTz'name' (or self.name)z (or `plot`)c3BK|]\}}|dt|yw)z: N)r=)r5r6values rr8z'_check_param_lengths..s(& '1sEse2c%j\ "& sz from `z` initializationz/, should all be lists of the same length. Got: )rrYrZr=valuesrjoinr.) requiredoptional class_nameoptional_providedrr all_paramsr6 param_keysparams_formattedor_plotlengths_formatteds r_check_param_lengthsrs(~~', e eT "&+ d #,3H2 12J J$5$5$7 85CJ 89A=%/__%67cc7 7#<<:cr?)CZPR^(TU "j 0$G II& 5?5E5E5G&    |3CG9M< 87s C4< C9)rVcollections.abcrnumpyr|rr_optional_dependenciesr _responserfixesr multiclassr validationr r r rzrr_rrrrr4rrrsS#%<2 &BjjZ'6#<~ &( r