
    -i                     V   S SK r S SKrS SKrS SKrS SKrS SKJr  S SKJrJ	r	  S SK
r
S SKrS SKJr  S SKJrJr  S SKJrJrJrJr  S SKJr  S SKJrJr  S SKJr  S S	KJ r J!r!J"r"  S S
K#J$r$J%r%J&r&J'r'  S SK(J)r)  S SK*J+r+  S SK,J-r-  S SK.J/r/J0r0  S SK1J2r2J3r3J4r4  S SK5J6r6J7r7  S SK8J9r9J:r:  S SK;J<r<J=r=J>r>J?r?J@r@JArA  S SKBJCrCJDrDJErEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrcJdrdJereJfrfJgrgJhrhJiriJjrjJkrk  S SKlJmrmJnrn  S SKoJprp  S SKqJrrr  S SKsJtrtJuruJvrvJwrw   " S S\x5      ry " S S\\5      rz " S S\5      r{ " S S\5      r| " S  S!\5      r} " S" S#\5      r~ " S$ S%\5      r " S& S'\5      r " S( S)\5      r " S* S+\5      r " S, S-\5      r " S. S/\z5      r " S0 S1\z5      r " S2 S3\z5      r " S4 S5\5      r " S6 S7\z5      r " S8 S9\5      r " S: S;\5      r " S< S=\5      r " S> S?\z5      r " S@ SA\5      r " SB SC\\5      r " SD SE\5      r " SF SG\'5      r " SH SI\5      r " SJ SK\$5      r " SL SM\$5      r " SN SO\%5      r " SP SQ\5      r " SR SS\5      rST rSU rSV rSW rSX rSY rSZ rS[ rS\ rS] rS^ rS_ rS` rSa rSb rSc rSd rSe rSf rSg rSh rSi rSj rSk rSl rSm rSn r " So Sp\\5      rSq rSr rSs rSt rSu rSv r\Sw:X  a  \" 5         Sx rSy rSz rS{ rS| rS} rS~ rS rS rS rS rS rS rS rS rS rS rS rS rg)    N)isgenerator)IntegralReal)config_context
get_config)BaseEstimatorClassifierMixinOutlierMixinTransformerMixin)MiniBatchKMeans)	load_irismake_multilabel_classification)PCA)ConvergenceWarningEstimatorCheckFailedWarningSkipTestWarning)LinearRegressionLogisticRegressionMultiTaskElasticNetSGDClassifier)GaussianMixture)KNeighborsRegressor)StandardScaler)SVCNuSVC)
_array_apiall_estimators
deprecated)Interval
StrOptions)_construct_instances_get_expected_failed_checks)MinimalClassifierMinimalRegressorMinimalTransformerSkipTestignore_warningsraises))_check_name_NotAnArray_yield_all_checkscheck_array_api_input-check_class_weight_balanced_linear_classifier"check_classifier_data_not_an_array*check_classifier_not_supporting_multiclass<check_classifiers_multilabel_output_format_decision_function2check_classifiers_multilabel_output_format_predict8check_classifiers_multilabel_output_format_predict_proba*check_classifiers_one_label_sample_weights(check_dataframe_column_names_consistency check_decision_proba_consistencycheck_dict_unchangedcheck_dont_overwrite_parameterscheck_estimatorcheck_estimator_cloneablecheck_estimator_reprcheck_estimator_sparse_arraycheck_estimator_sparse_matrixcheck_estimator_sparse_tagcheck_estimator_tags_renamedcheck_estimators_nan_inf!check_estimators_overwrite_paramscheck_estimators_unfittedcheck_fit_check_is_fittedcheck_fit_score_takes_y%check_methods_sample_order_invariancecheck_methods_subset_invariancecheck_mixin_ordercheck_no_attributes_set_in_initcheck_outlier_contaminationcheck_outlier_corruption&check_parameters_default_constructible"check_positive_only_tag_during_fit!check_regressor_data_not_an_arraycheck_requires_y_none"check_sample_weights_pandas_seriescheck_set_paramsestimator_checks_generatorset_random_state)CSR_CONTAINERSSPARRAY_PRESENT)available_if)type_of_target)check_arraycheck_is_fitted	check_X_yvalidate_datac                       \ rS rSrSrSrg)CorrectNotFittedErrorl   zException class to raise if estimator is used before fitting.

Like NotFittedError, it inherits from ValueError, but not from
AttributeError. Used for testing only.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r]       \/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/tests/test_estimator_checks.pyr[   r[   l   s    rd   r[   c                        \ rS rSrS rS rSrg)BaseBadClassifiert   c                     U $ Nr]   selfXys      re   fitBaseBadClassifier.fitu       rd   c                 H    [         R                  " UR                  S   5      $ Nr   nponesshaperl   rm   s     re   predictBaseBadClassifier.predictx   s    wwqwwqz""rd   r]   Nr^   r_   r`   ra   ro   ry   rc   r]   rd   re   rg   rg   t   s    #rd   rg   c                   .    \ rS rSrSS jrSS jrS rSrg)	ChangesDict|   c                     Xl         g rj   key)rl   r   s     re   __init__ChangesDict.__init__}   s    rd   Nc                 "    [        XU5      u  pU $ rj   rY   rk   s      re   ro   ChangesDict.fit       Ta(rd   c                 l    [        U5      nSU l        [        R                  " UR                  S   5      $ )Ni  r   )rV   r   ru   rv   rw   rx   s     re   ry   ChangesDict.predict   s)    Nwwqwwqz""rd   r   r   rj   r^   r_   r`   ra   r   ro   ry   rc   r]   rd   re   r}   r}   |   s    #rd   r}   c                   (    \ rS rSrSS jrSS jrSrg)SetsWrongAttribute   c                     Xl         g rj   )acceptable_key)rl   r   s     re   r   SetsWrongAttribute.__init__   s    ,rd   Nc                 0    SU l         [        XU5      u  pU $ rs   wrong_attributerY   rk   s      re   ro   SetsWrongAttribute.fit        Ta(rd   )r   r   r   rj   r^   r_   r`   ra   r   ro   rc   r]   rd   re   r   r      s    -rd   r   c                   (    \ rS rSrSS jrSS jrSrg)ChangesWrongAttribute   c                     Xl         g rj   r   )rl   r   s     re   r   ChangesWrongAttribute.__init__       .rd   Nc                 0    SU l         [        XU5      u  pU $ N   r   rk   s      re   ro   ChangesWrongAttribute.fit   r   rd   r   r   rj   r   r]   rd   re   r   r      s    /rd   r   c                       \ rS rSrSS jrSrg)ChangesUnderscoreAttribute   Nc                 0    SU l         [        XU5      u  pU $ r   )_good_attributerY   rk   s      re   ro   ChangesUnderscoreAttribute.fit   r   rd   )r   rj   r^   r_   r`   ra   ro   rc   r]   rd   re   r   r      s    rd   r   c                   <   ^  \ rS rSrSS jrU 4S jrSS jrSrU =r$ )RaisesErrorInSetParams   c                     Xl         g rj   prl   r   s     re   r   RaisesErrorInSetParams.__init__       rd   c                    > SU;   a(  UR                  S5      nUS:  a  [        S5      eX l        [        TU ]  " S0 UD6$ )Nr   r   zp can't be less than 0r]   )pop
ValueErrorr   super
set_paramsrl   kwargsr   	__class__s      re   r   !RaisesErrorInSetParams.set_params   sB    &=

3A1u !9::Fw!+F++rd   c                 "    [        XU5      u  pU $ rj   r   rk   s      re   ro   RaisesErrorInSetParams.fit   r   rd   r   r   rj   	r^   r_   r`   ra   r   r   ro   rc   __classcell__r   s   @re   r   r          , rd   r   c                   4    \ rS rSr\" 5       4S jrSS jrSrg)HasMutableParameters   c                     Xl         g rj   r   r   s     re   r   HasMutableParameters.__init__   r   rd   Nc                 "    [        XU5      u  pU $ rj   r   rk   s      re   ro   HasMutableParameters.fit   r   rd   r   rj   )r^   r_   r`   ra   objectr   ro   rc   r]   rd   re   r   r      s     rd   r   c                   N    \ rS rSrS\R
                  " S5      \4S jrSS jrSr	g)HasImmutableParameters   *   c                 (    Xl         X l        X0l        g rj   r   qr)rl   r   r   r   s       re   r   HasImmutableParameters.__init__   s    rd   Nc                 "    [        XU5      u  pU $ rj   r   rk   s      re   ro   HasImmutableParameters.fit   r   rd   r   rj   )
r^   r_   r`   ra   ru   int32r   r   ro   rc   r]   rd   re   r   r      s    rxx|v 
rd   r   c                   <   ^  \ rS rSrSS jrU 4S jrSS jrSrU =r$ )"ModifiesValueInsteadOfRaisingError   c                     Xl         g rj   r   r   s     re   r   +ModifiesValueInsteadOfRaisingError.__init__   r   rd   c                 n   > SU;   a  UR                  S5      nUS:  a  SnX l        [        TU ]  " S0 UD6$ )Nr   r   r]   )r   r   r   r   r   s      re   r   -ModifiesValueInsteadOfRaisingError.set_params   s;    &=

3A1uFw!+F++rd   c                 "    [        XU5      u  pU $ rj   r   rk   s      re   ro   &ModifiesValueInsteadOfRaisingError.fit   r   rd   r   r   rj   r   r   s   @re   r   r      r   rd   r   c                   <   ^  \ rS rSrSS jrU 4S jrSS jrSrU =r$ )ModifiesAnotherValue   c                     Xl         X l        g rj   ab)rl   r   r   s      re   r   ModifiesAnotherValue.__init__   s    rd   c                    > SU;   a2  UR                  S5      nX l        Uc  UR                  S5        SU l        [        TU ]  " S0 UD6$ )Nr   r   method2r]   )r   r   r   r   r   )rl   r   r   r   s      re   r   ModifiesAnotherValue.set_params   sF    &=

3AFy

3"w!+F++rd   c                 "    [        XU5      u  pU $ rj   r   rk   s      re   ro   ModifiesAnotherValue.fit   r   rd   r   )r   method1rj   r   r   s   @re   r   r      s    , rd   r   c                       \ rS rSrS rSrg)NoCheckinPredict   c                 "    [        XU5      u  pU $ rj   r   rk   s      re   ro   NoCheckinPredict.fit   r   rd   r]   Nr   r]   rd   re   r   r      s    rd   r   c                   *    \ rS rSrSS jrS rS rSrg)NoSparseClassifier   Nc                     Xl         g rj   raise_for_typerl   r   s     re   r   NoSparseClassifier.__init__       ,rd   c                     [        XUSS/S9u  pU R                  S:X  a  [        U[        R                  5      nO*U R                  S:X  a  [        U[        R
                  5      nW(       a  [        S5      eU $ )Ncsrcscaccept_sparsesparse_arraysparse_matrixNonsensical Error)rY   r   
isinstancespsparrayspmatrixr   rl   rm   rn   correct_types       re   ro   NoSparseClassifier.fit   sf    Tau~F.0%a4L  O3%a5L011rd   c                 ^    [        U5      n[        R                  " UR                  S   5      $ rs   rV   ru   rv   rw   rx   s     re   ry   NoSparseClassifier.predict  "    Nwwqwwqz""rd   r   rj   r   r]   rd   re   r   r      s    -#rd   r   c                        \ rS rSrS rS rSrg)CorrectNotFittedErrorClassifieri	  c                 r    [        XU5      u  p[        R                  " UR                  S   5      U l        U $ r   )rY   ru   rv   rw   coef_rk   s      re   ro   #CorrectNotFittedErrorClassifier.fit
  s-    Ta(WWQWWQZ(
rd   c                 t    [        U 5        [        U5      n[        R                  " UR                  S   5      $ rs   )rW   rV   ru   rv   rw   rx   s     re   ry   'CorrectNotFittedErrorClassifier.predict  s*    Nwwqwwqz""rd   )r  Nr{   r]   rd   re   r  r  	  s    
#rd   r  c                   $    \ rS rSrSS jrS rSrg)NoSampleWeightPandasSeriesTypei  Nc           	      f    [        XUSSSS9u  pSSKJn  [        X45      (       a  [	        S5      eU $ )Nr   r   Tr   multi_output	y_numericr   Seriesz>Estimator does not accept 'sample_weight'of type pandas.Series)rY   pandasr  r  r   )rl   rm   rn   sample_weightr  s        re   ro   "NoSampleWeightPandasSeriesType.fit  sA    Qn4SW
 	"m,,P  rd   c                 ^    [        U5      n[        R                  " UR                  S   5      $ rs   r  rx   s     re   ry   &NoSampleWeightPandasSeriesType.predict$  r  rd   r]   rj   r{   r]   rd   re   r  r    s    #rd   r  c                   $    \ rS rSrSS jrS rSrg)BadBalancedWeightsClassifieri)  Nc                     Xl         g rj   )class_weight)rl   r&  s     re   r   %BadBalancedWeightsClassifier.__init__*  s    (rd   c                     SSK Jn  SSKJn  U" 5       R	                  U5      nUR
                  nU" U R                  XbS9nU R                  S:X  a  US-  nXpl        U $ )Nr   )LabelEncoder)compute_class_weight)classesrn   balanced      ?)sklearn.preprocessingr)  sklearn.utilsr*  ro   classes_r&  r  )rl   rm   rn   r)  r*  label_encoderr+  r&  s           re   ro    BadBalancedWeightsClassifier.fit-  s]    66$**1-((+D,=,=wT 
*CL "
rd   )r&  r  rj   r   r]   rd   re   r$  r$  )  s    )rd   r$  c                   $    \ rS rSrSS jrS rSrg)BadTransformerWithoutMixini?  Nc                     [        X5      nU $ rj   r   rk   s      re   ro   BadTransformerWithoutMixin.fit@  s    $"rd   c                 0    [        U 5        [        XSS9nU$ )NFreset)rW   rY   rx   s     re   	transform$BadTransformerWithoutMixin.transformD  s    $/rd   r]   rj   )r^   r_   r`   ra   ro   r:  rc   r]   rd   re   r4  r4  ?  s    rd   r4  c                        \ rS rSrS rS rSrg)NotInvariantPredictiJ  c           	      $    [        XUSSSS9u  pU $ Nr  Tr  r   rk   s      re   ro   NotInvariantPredict.fitK  s!    Qn4SW
 rd   c                     [        U5      nUR                  S   S:  a#  [        R                  " UR                  S   5      $ [        R                  " UR                  S   5      $ )Nr   r   )rV   rw   ru   rv   zerosrx   s     re   ry   NotInvariantPredict.predictR  sH    N771:>771771:&&xx
##rd   r]   Nr{   r]   rd   re   r=  r=  J  s    $rd   r=  c                        \ rS rSrS rS rSrg)NotInvariantSampleOrderiZ  c           	      0    [        XUSSSS9u  pXl        U $ r?  )rY   _Xrk   s      re   ro   NotInvariantSampleOrder.fit[  s&    Qn4SW
 rd   c                 J   [        U5      n[        R                  " [        R                  " USS9[        R                  " U R                  SS95      (       aD  XR                  :g  R                  5       (       a#  [        R                  " UR                  S   5      $ US S 2S4   $ )Nr   )axis)rV   ru   array_equivsortrG  anyrB  rw   rx   s     re   ry   NotInvariantSampleOrder.predictc  sq    N NN27711-rwwtwwQ/GHHgg""$$88AGGAJ''Awrd   )rG  Nr{   r]   rd   re   rE  rE  Z  s    	rd   rE  c                   2    \ rS rSrSrSS jrS	S jrS rSrg)
OneClassSampleErrorClassifierio  zkClassifier allowing to trigger different behaviors when `sample_weight` reduces
the number of classes to 1.c                     Xl         g rj   )raise_when_single_class)rl   rR  s     re   r   &OneClassSampleErrorClassifier.__init__s  s    '>$rd   Nc                    [        XSSSS9u  pSU l        [        R                  " USS9u  U l        nU R                  R
                  S   nUS:  a#  U R                  (       a  SU l        [        S5      eUbp  [        U[        R                  5      (       a9  [        U5      S:  a*  [        R                  " [        R                  " X#5      5      nUS:  a  SU l        [        S	5      eU $ )
Nr  Tr  F)return_inverser      znormal class errorr  )rX   has_single_class_ru   uniquer0  rw   rR  r   r  ndarraylencount_nonzerobincount)rl   rm   rn   r  
n_classes_s        re   ro   !OneClassSampleErrorClassifier.fitv  s    TT
 "'99Qt<q]]((+
>d::%)D"122 $-44]9Ka9O--bkk!.KL
A~)-& !455rd   c                     [        U 5        [        U5      nU R                  (       a#  [        R                  " UR
                  S   5      $ [        R                  " UR
                  S   5      $ rs   )rW   rV   rW  ru   rB  rw   rv   rx   s     re   ry   %OneClassSampleErrorClassifier.predict  sJ    N!!88AGGAJ''wwqwwqz""rd   )r0  rW  rR  )Frj   	r^   r_   r`   ra   rb   r   ro   ry   rc   r]   rd   re   rP  rP  o  s    #?,#rd   rP  c                   (    \ rS rSrSrSS jrS rSrg)!LargeSparseNotSupportedClassifieri  zZEstimator that claims to support large sparse data
(accept_large_sparse=True), but doesn'tNc                     Xl         g rj   r   r   s     re   r   *LargeSparseNotSupportedClassifier.__init__  r   rd   c           
         [        U UUSSSSS9u  pU R                  S:X  a  [        U[        R                  5      nO*U R                  S:X  a  [        U[        R
                  5      nW(       a  UR                  S:X  aB  UR                  R                  S:X  d  UR                  R                  S:X  a  [        S5      e U $ UR                  S	;   a7  SUR                  R                  UR                  R                  4;  d   S5       eU $ )
N)r   r   cooT)r   accept_large_sparser  r  r   r  rg  int64z(Estimator doesn't support 64-bit indices)r   r   )rY   r   r  r  r  r  formatrowdtypecolr   indicesindptrr  s       re   ro   %LargeSparseNotSupportedClassifier.fit  s    / $
 .0%a4L  O3%a5Lxx5 55;;')QUU[[G-C$%OPP .D  ^+IIOOHHNN'  > >> 
 rd   r   rj   )r^   r_   r`   ra   rb   r   ro   rc   r]   rd   re   rc  rc    s    /-rd   rc  c                   8    \ rS rSrSS jrSS jrSS jrS rSrg)	SparseTransformeri  Nc                     Xl         g rj   sparse_container)rl   ru  s     re   r   SparseTransformer.__init__  s     0rd   c                     [        X5        U $ rj   r   rk   s      re   ro   SparseTransformer.fit  s    drd   c                 B    U R                  X5      R                  U5      $ rj   )ro   r:  rk   s      re   fit_transformSparseTransformer.fit_transform  s    xx~''**rd   c                 P    [        U 5        [        XSSS9nU R                  U5      $ )NTF)r   r9  )rW   rY   ru  rx   s     re   r:  SparseTransformer.transform  s)    $UC$$Q''rd   rt  rj   )	r^   r_   r`   ra   r   ro   rz  r:  rc   r]   rd   re   rr  rr    s    1+(rd   rr  c                        \ rS rSrS rS rSrg)EstimatorInconsistentForPandasi  c                      SSK Jn  [        X5      (       a  UR                  S   U l        U $ [        U5      nUS   U l        U $ ! [         a    [        U5      nUS   U l        U s $ f = f)Nr   )	DataFrame)r   r   )r   r   )r  r  r  ilocvalue_rV   ImportError)rl   rm   rn   r  s       re   ro   "EstimatorInconsistentForPandas.fit  sn    	(!''ffTl K  NgK 	AAD'DKK	s   +A A !A)(A)c                 z    [        U5      n[        R                  " U R                  /UR                  S   -  5      $ rs   )rV   ru   arrayr  rw   rx   s     re   ry   &EstimatorInconsistentForPandas.predict  s-    Nxx
233rd   )r  Nr{   r]   rd   re   r  r    s     4rd   r  c                   <   ^  \ rS rSrSU 4S jjrSU 4S jjrSrU =r$ )UntaggedBinaryClassifieri  c                 r   > [         TU ]  XX4U5        [        U R                  5      S:  a  [	        S5      eU $ )NrV  Only 2 classes are supported)r   ro   rZ  r0  r   )rl   rm   rn   	coef_initintercept_initr  r   s         re   ro   UntaggedBinaryClassifier.fit  s5    A)]Ct}}!;<<rd   c                 l   > [         TU ]  XX4S9  [        U R                  5      S:  a  [	        S5      eU $ )N)rm   rn   r+  r  rV  r  )r   partial_fitrZ  r0  r   )rl   rm   rn   r+  r  r   s        re   r  $UntaggedBinaryClassifier.partial_fit  s7    agSt}}!;<<rd   r]   )NNNNN)r^   r_   r`   ra   ro   r  rc   r   r   s   @re   r  r    s     rd   r  c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )TaggedBinaryClassifieri  c                 b   > [        USSS9nUS:w  a  [        SU S35      e[        TU ]  X5      $ )Nrn   T)
input_nameraise_unknownbinaryzCOnly binary classification is supported. The type of the target is .)rU   r   r   ro   )rl   rm   rn   y_typer   s       re   ro   TaggedBinaryClassifier.fit  sH    cFXXQ   w{1  rd   c                 F   > [         TU ]  5       nSUR                  l        U$ NF)r   __sklearn_tags__classifier_tagsmulti_classrl   tagsr   s     re   r  'TaggedBinaryClassifier.__sklearn_tags__  s#    w')+0(rd   r]   r^   r_   r`   ra   ro   r  rc   r   r   s   @re   r  r    s    ! rd   r  c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )RequiresPositiveXRegressori  c                    > [        XUSSS9u  pUS:  R                  5       (       a  [        S5      e[        TU ]  X5      $ )NFTr   r  r   z$Negative values in data passed to X.rY   rM  r   r   ro   rl   rm   rn   r   s      re   ro   RequiresPositiveXRegressor.fit  s?    Tau4PE;;==CDDw{1  rd   c                 h   > [         TU ]  5       nSUR                  l        SUR                  l        U$ )NTF)r   r  
input_tagspositive_onlysparser  s     re   r  +RequiresPositiveXRegressor.__sklearn_tags__  s-    w')(,%!&rd   r]   r  r   s   @re   r  r    s    ! rd   r  c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )RequiresPositiveYRegressori  c                    > [        XUSSS9u  pUS:*  R                  5       (       a  [        S5      e[        TU ]  X5      $ )NTr  r    negative y values not supported!r  r  s      re   ro   RequiresPositiveYRegressor.fit  s?    Tat$OF<<>>?@@w{1  rd   c                 F   > [         TU ]  5       nSUR                  l        U$ NT)r   r  target_tagsr  r  s     re   r  +RequiresPositiveYRegressor.__sklearn_tags__  s#    w'))-&rd   r]   r  r   s   @re   r  r    s    ! rd   r  c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )PoorScoreLogisticRegressioni  c                 (   > [         TU ]  U5      S-   $ r   )r   decision_function)rl   rm   r   s     re   r  -PoorScoreLogisticRegression.decision_function  s    w(+a//rd   c                 F   > [         TU ]  5       nSUR                  l        U$ r  )r   r  r  
poor_scorer  s     re   r  ,PoorScoreLogisticRegression.__sklearn_tags__  s#    w')*.'rd   r]   )r^   r_   r`   ra   r  r  rc   r   r   s   @re   r  r    s    0 rd   r  c                        \ rS rSrS rS rSrg)PartialFitChecksNamei%  c                     [        XU5        U $ rj   r   rk   s      re   ro   PartialFitChecksName.fit&  s    dq!rd   c                 J    [        U S5      (       + n[        XX#S9  SU l        U $ )N_fittedr8  T)hasattrrY   r  )rl   rm   rn   r9  s       re   r   PartialFitChecksName.partial_fit*  s'    D),,dq.rd   )r  N)r^   r_   r`   ra   ro   r  rc   r]   rd   re   r  r  %  s    rd   r  c                   $    \ rS rSrSrS rS rSrg)BrokenArrayAPIi1  z=Make different predictions when using Numpy and the Array APIc                     U $ rj   r]   rk   s      re   ro   BrokenArrayAPI.fit4  rq   rd   c                     [        5       S   n[        R                  " U5      u  p4U(       a  UR                  / SQ5      $ [        R
                  " / SQ5      $ )Narray_api_dispatch)r   rV     )r  rV  r   )r   r   get_namespaceasarrayru   r  )rl   rm   enabledxp_s        re   ry   BrokenArrayAPI.predict7  sB    ,34((+::i((88I&&rd   r]   N)r^   r_   r`   ra   rb   ro   ry   rc   r]   rd   re   r  r  1  s    G'rd   r  c                       [         R                  " S5        [	        [
        SS9   [        S[        5       SSS9  S S S 5        g ! [         a    [        S5      ef = f! , (       d  f       g = f)Narray_api_strictz-array-api-strict is required to run this testNot equal to tolerancematchr  T)array_namespacecheck_values)	importlibimport_moduleModuleNotFoundErrorr&   r(   AssertionErrorr,   r  r]   rd   re   test_check_array_api_inputr  @  sm    H 23 
&>	?.		
 
@	?  HFGGH 
@	?s   A AA
A+c                      [        [        R                  " S5      5      n Sn[        [        US9   [        R
                  " U 5        S S S 5        [        R                  " U S 5      (       d   eg ! , (       d  f       N-= f)N
   z&Don't want to call array_function sum!r  )r*   ru   rv   r(   	TypeErrorsummay_share_memory)	not_arraymsgs     re    test_not_an_array_array_functionr  O  sX    BGGBK(I
2C			%
y 
& y$//// 
&	%s   A..
A<c                  D     " S S[         5      n [        SU " 5       5        g )Nc                   0    \ rS rSr\" S5      S 5       rSrg)btest_check_fit_score_takes_y_works_on_deprecated_fit.<locals>.TestEstimatorWithDeprecatedFitMethodi\  z=Deprecated for the purpose of testing check_fit_score_takes_yc                     U $ rj   r]   rk   s      re   ro   ftest_check_fit_score_takes_y_works_on_deprecated_fit.<locals>.TestEstimatorWithDeprecatedFitMethod.fit]  s    Krd   r]   N)r^   r_   r`   ra   r   ro   rc   r]   rd   re   $TestEstimatorWithDeprecatedFitMethodr  \  s    	S	T	 
U	rd   r  test)r   rC   )r  s    re   4test_check_fit_score_takes_y_works_on_deprecated_fitr  X  s    } 
 F$H$JKrd   c                  v    Sn [        [        U S9   [        [        5        SSS5        g! , (       d  f       g= f)z7Test that passing a class instead of an instance fails.zPassing a class was deprecatedr  N)r(   r  r8   r   r  s    re   'test_check_estimator_with_class_removedr  d  s&    
*C			%*+ 
&	%	%s   *
8c                      Sn [        S[        5       5        [        [        U S9   [        S[	        5       5        SSS5        g! , (       d  f       g= f)z=Test that constructor cannot have mutable default parameters.zXParameter 'p' of estimator 'HasMutableParameters' is of type object which is not allowed	Immutabler  MutableN)rJ   r   r(   r  r   r  s    re   test_mutable_default_paramsr  k  sE    	& 
 ++- 
c	*.y:N:PQ 
+	*	*s   A
Ac                     Sn [        [        U S9   [        S[        5       5        SSS5        [        R
                  " SS9 n[        S[        5       5        SSS5        [        W Vs/ s H  o"R                  PM     sn;   d   e[        [        U S9   [        S[        5       5        SSS5        g! , (       d  f       N= f! , (       d  f       Nq= fs  snf ! , (       d  f       g= f)z8Check set_params doesn't fail and sets the right values.z>get_params result does not match what was passed to set_paramsr  r  NTrecord)
r(   r  rO   r   warningscatch_warningsr   UserWarningcategoryr   )r  recordsrecs      re   test_check_set_paramsr  y  s     KC	c	*!C!EF 
+ 
	 	 	-!7!9: 
.7;7C<<7;;;;	c	*!5!78 
+	* 
+	* 
.	-;	*	*s)   B1C(CC1
B?
C
C&c                      Sn [        [        U S9   [        S[        5       5        S S S 5        g ! , (       d  f       g = f)NzCEstimator NoCheckinPredict doesn't check for NaN and inf in predictr  r   )r(   r  r?   r   r  s    re   test_check_estimators_nan_infr    s,    
OC	c	* !35E5GH 
+	*	*   /
=c                      Sn [        [        U S9   [        S[        5       5        S S S 5        g ! , (       d  f       g = f)Nz)Estimator changes __dict__ during predictr  r  )r(   r  r6   r}   r  s    re   test_check_dict_unchangedr	    s+     6C	c	*V[]3 
+	*	*r  c                       SSK Jn   Sn[        [        US9   [	        S[        5       5        S S S 5        g ! , (       d  f       g = f! [         a     g f = f)Nr   r  zkEstimator NoSampleWeightPandasSeriesType raises error if 'sample_weight' parameter is of type pandas.Seriesr  r  )r  r  r(   r   rN   r  r  )r  r  s     re   'test_check_sample_weights_pandas_seriesr    sQ    !A 	 Jc*.02P2R +**  s+   A 6A 
A A A 
AAc                      Sn [        [        U S9   [        S[        5       5        S S S 5        [        S[	        5       5        g ! , (       d  f       N#= f)NzrEstimator ChangesWrongAttribute should not change or mutate  the parameter wrong_attribute from 0 to 1 during fit.r  r   r  )r(   r  r@   r   r   r  s    re   &test_check_estimators_overwrite_paramsr    sH    	@  
c	*)#%:%<	
 
+ &f.H.JK	 
+	*   A
Ac                      Sn [        [        U S9   [        S[        5       5        S S S 5        g ! , (       d  f       g = f)NzEstimator adds public attribute\(s\) during the fit method. Estimators are only allowed to add private attributes either started with _ or ended with _ but wrong_attribute addedr  r  )r(   r  r7   r   r  s    re   $test_check_dont_overwrite_parametersr    s2    	,  
c	*'0B0DE 
+	*	*r  c                      [         R                  n SnSR                  XS9n[        [        US9   [        S[        5       5        S S S 5        g ! , (       d  f       g = f)Nry   zY{method} of {name} is not invariant when applied to a datasetwith different sample order.methodnamer  rE  )rE  r^   rj  r(   r  rD   r  r  r  s      re   *test_check_methods_sample_order_invariancer    sQ    "++DF	'fFf&  
c	*-%'>'@	
 
+	*	*   A
Ac                      [         R                  n SnSR                  XS9n[        [        US9   [        S[        5       5        S S S 5        g ! , (       d  f       g = f)Nry   z={method} of {name} is not invariant when applied to a subset.r  r  r=  )r=  r^   rj  r(   r  rE   r  s      re   $test_check_methods_subset_invariancer    sR    ''DFJ
R
R S C 
c	*'(=?R?TU 
+	*	*r  c                  H   [         R                  n SU -  n[        [        US9   [	        U [        S5      5        S S S 5        [
        (       a,  [        [        US9   [        U [        S5      5        S S S 5        Sn[        [        US9   [	        S[        S5      5        S S S 5        [
        (       a-  [        [        US9   [        S[        S5      5        S S S 5        g g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       Ni= f! , (       d  f       g = f)Nz;Estimator %s doesn't seem to fail gracefully on sparse datar  r  r   ztEstimator LargeSparseNotSupportedClassifier doesn't seem to support \S{3}_64 matrix, and is not failing gracefully.*rc  )r   r^   r(   r  r<   rS   r;   rc  r  r  s     re    test_check_estimator_sparse_datar    s    &&D
G$
NC	c	*%d,>,OP 
+ N#.(/A./QR /
	D  
c	*%/-o>	
 
+ N#.(31.A /. % 
+	* /. 
+	* /.s/   C C1	D D 
C.1
C?
D
D!c                      [         R                  n U  S3n[        [        US9   [	        S[        5       5        S S S 5        g ! , (       d  f       g = f)Nzu failed when fitted on one label after sample_weight trimming. Error message is not explicit, it should have 'class'.r  rP  )rP  r^   r(   r  r3   r  s     re   /test_check_classifiers_one_label_sample_weightsr    sJ    (11D&  	 
 
c	*2+-J-L	
 
+	*	*s   A
Ac                     [        [        5       SS9n [        U [        5      (       d   e[	        U 5      S:  d   e[        S U  5       5      (       d   e[        S U  5       5      (       d   e[        S U  5       5      (       d   eg)zCheck the contents of the results returned with on_fail!="raise".

This results should contain details about the observed failures, expected
or not.
N)on_failr   c              3      #    U  H:  n[        U[        5      =(       a    [        UR                  5       5      1 S k:H  v   M<     g7f)>   status	estimator	exception
check_nameexpected_to_failexpected_to_fail_reasonN)r  dictsetkeys.0items     re   	<genexpr>5test_check_estimator_not_fail_fast.<locals>.<genexpr>  sD       "D 	4 		
		

		
 "s   AAc              3   0   #    U  H  oS    S:H  v   M     g7f)r"  failedNr]   r+  s     re   r.  r/         DmdH~)m   c              3   0   #    U  H  oS    S:H  v   M     g7f)r"  passedNr]   r+  s     re   r.  r/    r2  r3  )r8   r   r  listrZ  allrM  )check_resultss    re   "test_check_estimator_not_fail_fastr9    s     $MOTBMmT****}!!!  "     DmDDDDDDmDDDDDrd   c                     Sn [        [        U S9   [        [        5       5        S S S 5        Sn [        [        U S9   [        [        5       5        S S S 5        [         H  n[        [        US95        M     [        [        5       5        [        [        SS95        [        [        5       5        [        [        5       5        [        [        5       5        Sn [        [        U S9   [        [        5       5        S S S 5        [        [        5       5        g ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       ND= f)Nzobject has no attribute 'fit'r  r  rt  g{Gz?)Cr  )r(   AttributeErrorr8   r   r   r  rR   rr  r   r   r  r  r  r  )r  csr_containers     re   test_check_estimatorr>  "  s    
 *C	c	*( 
+ )C	
#	&023 
' ()=IJ (
 &()&./')* *,-.01 -C	
#	&245 
' /127 
+	*
 
'	&$ 
'	&s"   DD'&D8
D$'
D58
Ec                      [         R                  " / SQ5      n [        [        5         [	        SSU 5        S S S 5        [         R                  " / SQ5      n [	        SSU 5        g ! , (       d  f       N4= f)N)        r-  g      ?       @r   rV  )r@  r-  r-  rA  )ru   r  r(   r  rI   )decisions    re   test_check_outlier_corruptionrC  F  sP    xx,-H		 Ax0 
  xx,-HQ8,	 
 	s   A$$
A2c                  R    " S S[         5      n SSSS.SSSS.SS[        S.SS[        S./nU Hq  nU " US   US   5      nUS	   c"  [        UR                  R                  U5        M:  [        US	   5         [        UR                  R                  U5        SSS5        Ms     [        S
5      [        S5      4 HE  nU " SSU5      n[        [        5         [        UR                  R                  U5        SSS5        MG     g! , (       d  f       M  = f! , (       d  f       Mk  = f)zPTest that check_estimator_sparse_tag raises error when sparse tag is
misaligned.c                   <   ^  \ rS rSrSS jrSS jrU 4S jrSrU =r$ )Btest_check_estimator_sparse_tag.<locals>.EstimatorWithSparseConfigiT  c                 (    Xl         X l        X0l        g rj   )
tag_sparser   	fit_error)rl   rH  r   rI  s       re   r   Ktest_check_estimator_sparse_tag.<locals>.EstimatorWithSparseConfig.__init__U  s    (O!.&Nrd   c                 h    U R                   (       a  U R                   e[        XX R                  S9  U $ )Nr   )rI  rY   r   rk   s      re   ro   Ftest_check_estimator_sparse_tag.<locals>.EstimatorWithSparseConfig.fitZ  s(    ~~nn$$14F4FGKrd   c                 Z   > [         TU ]  5       nU R                  UR                  l        U$ rj   )r   r  rH  r  r  r  s     re   r  Stest_check_estimator_sparse_tag.<locals>.EstimatorWithSparseConfig.__sklearn_tags__`  s%    7+-D%)__DOO"Krd   )r   rI  rH  rj   	r^   r_   r`   ra   r   ro   r  rc   r   r   s   @re   EstimatorWithSparseConfigrF  T  s    	'
		 	rd   rP  TN)rH  r   
error_typeFrH  r   rQ  zunexpected errorzother error)r   r  r=   r   r^   r(   r  KeyError)rP  
test_cases	test_caser#  rI  s        re   test_check_estimator_sparse_tagrU  P  s   M $ d$GuDIt>Re>R	J  	-l#o&
	 \"*&y':':'C'CYO	,/0*9+>+>+G+GS 10     23Xm5LM	-eUIF	N#&y':':'C'CYO $# N 10 $#s   8!D!D
D	
D&	c                  ~    [        [        S5         [        [        5       5        S S S 5        g ! , (       d  f       g = f)Nz%the `transformer_tags` tag is not set)r(   RuntimeErrorr8   r4  r]   rd   re   )test_check_estimator_transformer_no_mixinrX    s(     
E	F245 
G	F	Fs   .
<c                     [        5       n [        [        [        [        [
        4 GH  n[        [        S9   U" 5       n[        U5        [        R                  " U5      n[        U[        U5      S9  S S S 5        W[        R                  " W5      :X  d   e[        [        S9   U" 5       n[        U5        UR                  U R                  U R                  5        [        R                  " U5      n[        U[        U5      S9  S S S 5        U[        R                  " U5      :X  a  GM   e   g ! , (       d  f       N= f! , (       d  f       NA= f)N)r  expected_failed_checks)r   r   r   r   r   r   r'   r   rQ   joblibhashr8   r"   ro   datatarget)iris	Estimatorestold_hashs       re   test_check_estimator_clonesrd    s    ;D 		 &89+CS!{{3'H,G,L	 : 6;;s++++ &89+CS!GGDIIt{{+{{3'H,G,L : 6;;s++++5 :9 :9s   <D0$A"E0
D>	
E	c                      Sn [        [        U S9   [        S[        5       5        S S S 5        [        S[	        5       5        g ! , (       d  f       N#= f)Nz4Estimator should raise a NotFittedError when callingr  r#  )r(   r  rA   r   r  r  s    re   test_check_estimators_unfittedrf    s@     AC	c	*!+/A/CD 
+
 k+J+LM 
+	*r  c                      " S S[         5      n  " S S[         5      n " S S[         5      nSn[        [        US9   [        S	U " 5       5        S S S 5        S
n[        [        US9   [        S	U" 5       5        S S S 5        [        S	U" 5       5        [        SS9   [        S	U" 5       R                  SS95        S S S 5        g ! , (       d  f       Nz= f! , (       d  f       Na= f! , (       d  f       g = f)Nc                       \ rS rSrS rSrg)Ntest_check_no_attributes_set_in_init.<locals>.NonConformantEstimatorPrivateSeti  c                     S U l         g rj   you_should_not_set_this_rl   s    re   r   Wtest_check_no_attributes_set_in_init.<locals>.NonConformantEstimatorPrivateSet.__init__  s
    ,0D)rd   rk  Nr^   r_   r`   ra   r   rc   r]   rd   re    NonConformantEstimatorPrivateSetri    s    	1rd   rp  c                       \ rS rSrSS jrSrg)Ntest_check_no_attributes_set_in_init.<locals>.NonConformantEstimatorNoParamSeti  Nc                     g rj   r]   )rl   you_should_set_this_s     re   r   Wtest_check_no_attributes_set_in_init.<locals>.NonConformantEstimatorNoParamSet.__init__  s    rd   r]   rj   ro  r]   rd   re    NonConformantEstimatorNoParamSetrr    s    	rd   rv  c                       \ rS rSrSS0rSrg)Otest_check_no_attributes_set_in_init.<locals>.ConformantEstimatorClassAttributei  fooTr]   N)r^   r_   r`   ra   9_ConformantEstimatorClassAttribute__metadata_request__fitrc   r]   rd   re   !ConformantEstimatorClassAttributerx    s    #($-rd   r{  zEstimator estimator_name should not set any attribute apart from parameters during init. Found attributes \['you_should_not_set_this_'\].r  estimator_namezPEstimator estimator_name should store all parameters as an attribute during initT)enable_metadata_routing)ry  )r   r(   r  rG   r<  r   set_fit_request)rp  rv  r{  r  s       re   $test_check_no_attributes_set_in_initr    s    1= 1= 0M 0
	= 
 
c	*'>@	
 
+	  
c	*'>@	
 
+ $;= 
	5'-/??D?I	
 
6	5+ 
+	* 
+	* 
6	5s#   C(CC&
C
C#&
C4c                  d    [        SS9n [        U 5        [        SS9n [        U [        U 5      S9  g )Nprecomputed)kernel)metricrZ  )r   r8   r   r"   )rb  s    re   test_check_estimator_pairwiser    s2    
 ]
#CC ]
3CC0KC0PQrd   c                  |    [        [        SS9   [        S[        5       5        S S S 5        g ! , (       d  f       g = fNr  r  r|  )r(   r  r.   r  r]   rd   re   'test_check_classifier_data_not_an_arrayr    s+    	&>	?*<>	
 
@	?	?   -
;c                  |    [        [        SS9   [        S[        5       5        S S S 5        g ! , (       d  f       g = fr  )r(   r  rL   r  r]   rd   re   &test_check_regressor_data_not_an_arrayr    s+    	&>	?)<>	
 
@	?	?r  c                     Sn [        [        U S9   [        S[        5       5        S S S 5        [        S[	        5       5        [        5       n[        UR                  R                  U5        SUl        Sn [        [        U S9   [        UR                  R                  U5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nz+Estimator does not have a feature_names_in_r  r|  z;Docstring that does not document the estimator's attributeszNEstimator LogisticRegression does not document its feature_names_in_ attribute)	r(   r   r4   rg   r  r   r   r^   rb   )err_msglrs     re   -test_check_dataframe_column_names_consistencyr    s    ;G	
'	*01ACTCVW 
+,-=?S?UV		B,R\\-B-BBGNBJX  

'	*01F1FK 
+	* 
+	* 
+	*s   B-!B>-
B;>
Cc                   4   ^  \ rS rSrS rS rU 4S jrSrU =r$ )_BaseMultiLabelClassifierMocki  c                     Xl         g rj   response_output)rl   r  s     re   r   &_BaseMultiLabelClassifierMock.__init__  r   rd   c                     U $ rj   r]   rk   s      re   ro   !_BaseMultiLabelClassifierMock.fit  rq   rd   c                 F   > [         TU ]  5       nSUR                  l        U$ r  )r   r  r  multi_labelr  s     re   r  ._BaseMultiLabelClassifierMock.__sklearn_tags__  s#    w')+/(rd   r  rO  r   s   @re   r  r    s    / rd   r  c            
         Su  pn[        U SUSSSSS9u  p4XA* S  n " S S	[        5      nU" UR                  5       S
9nSn[        [        US9   [        UR                  R                  U5        S S S 5        U" US S 2S S24   S
9nSn[        [        US9   [        UR                  R                  U5        S S S 5        U" UR                  [        R                  5      S
9nSn[        [        US9   [        UR                  R                  U5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N|= f! , (       d  f       g = f)Nd         rV  r  2   Tr   	n_samples
n_features	n_classesn_labelslengthallow_unlabeledrandom_statec                       \ rS rSrS rSrg)\test_check_classifiers_multilabel_output_format_predict.<locals>.MultiLabelClassifierPredicti'  c                     U R                   $ rj   r  rx   s     re   ry   dtest_check_classifiers_multilabel_output_format_predict.<locals>.MultiLabelClassifierPredict.predict(      '''rd   r]   N)r^   r_   r`   ra   ry   rc   r]   rd   re   MultiLabelClassifierPredictr  '      	(rd   r  r  zdMultiLabelClassifierPredict.predict is expected to output a NumPy array. Got <class 'list'> instead.r  zbMultiLabelClassifierPredict.predict outputs a NumPy array of shape \(25, 4\) instead of \(25, 5\).zTMultiLabelClassifierPredict.predict does not output the same dtype than the targets.)r   r  tolistr(   r  r1   r   r^   astyperu   float64)	r  	test_size	n_outputsr  rn   y_testr  clfr  s	            re   7test_check_classifiers_multilabel_output_format_predictr    s8   &0#I))DA z{^F(&C (
 &fmmo
FC	4  
g	.:3==;Q;QSVW 
/ &fQVn
EC	1  
g	.:3==;Q;QSVW 
/ &fmmBJJ6O
PC	#  
g	.:3==;Q;QSVW 
/	.! 
/	. 
/	. 
/	.s$   !D!D.3!D?
D+.
D<?
Ec            
         Su  pn[        U SUSSSSS9u  p4XA* S  n " S S	[        5      n[         HV  nU" U" U5      S
9nSUR                   S3n	[	        [
        U	S9   [        UR                  R                  U5        S S S 5        MX     U" UR                  5       S
9nSU SU S3n	[	        [        U	S9   [        UR                  R                  U5        S S S 5        [        U5       Vs/ s H  n[        R                  " U5      PM     n
nU" U
S
9nSn	[	        [        U	S9   [        UR                  R                  U5        S S S 5        [        U5       Vs/ s H5  n[        R                  " UR                  S   S4[        R                  S9PM7     n
nU" U
S
9nSn	[	        [        U	S9   [        UR                  R                  U5        S S S 5        [        U5       Vs/ s H5  n[        R                  " UR                  S   S4[        R                   S9PM7     n
nU" U
S
9nSn	[	        [        U	S9   [        UR                  R                  U5        S S S 5        U" US S 2S S24   S
9nSn	[	        [        U	S9   [        UR                  R                  U5        S S S 5        [        R"                  " U[        R                  S9n
U" U
S
9nSn	[	        [        U	S9   [        UR                  R                  U5        S S S 5        U" US-  S
9nSn	[	        [        U	S9   [        UR                  R                  U5        S S S 5        g ! , (       d  f       GM-  = f! , (       d  f       GN= fs  snf ! , (       d  f       GN:= fs  snf ! , (       d  f       GN= fs  snf ! , (       d  f       GNT= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       g = f)Nr  rV  r  r  Tr   r  c                       \ rS rSrS rSrg)gtest_check_classifiers_multilabel_output_format_predict_proba.<locals>.MultiLabelClassifierPredictProbaiR  c                     U R                   $ rj   r  rx   s     re   predict_probautest_check_classifiers_multilabel_output_format_predict_proba.<locals>.MultiLabelClassifierPredictProba.predict_probaS  r  rd   r]   N)r^   r_   r`   ra   r  rc   r]   rd   re    MultiLabelClassifierPredictProbar  R  r  rd   r  r  zUnknown returned type .*zZ.* by MultiLabelClassifierPredictProba.predict_proba. A list or a Numpy array is expected.r  zWhen MultiLabelClassifierPredictProba.predict_proba returns a list, the list should be of length n_outputs and contain NumPy arrays. Got length of z instead of r  zWhen MultiLabelClassifierPredictProba.predict_proba returns a list, this list should contain NumPy arrays of shape \(n_samples, 2\). Got NumPy arrays of shape \(25, 5\) instead of \(25, 2\).)rw   rl  zwWhen MultiLabelClassifierPredictProba.predict_proba returns a list, it should contain NumPy arrays with floating dtype.zWhen MultiLabelClassifierPredictProba.predict_proba returns a list, each NumPy array should contain probabilities for each class and thus each row should sum to 1r  zWhen MultiLabelClassifierPredictProba.predict_proba returns a NumPy array, the expected shape is \(n_samples, n_outputs\). Got \(25, 4\) instead of \(25, 5\).)rl  znWhen MultiLabelClassifierPredictProba.predict_proba returns a NumPy array, the expected data type is floating.rA  zWhen MultiLabelClassifierPredictProba.predict_proba returns a NumPy array, this array is expected to provide probabilities of the positive class and should therefore contain values between 0 and 1.)r   r  rR   r^   r(   r   r2   r   r  r  rangeru   	ones_likerv   rw   ri  r  
zeros_like)r  r  r  r  rn   r  r  r=  r  r  r  s              re   =test_check_classifiers_multilabel_output_format_predict_probar  E  s   &0#I))DA z{^F(+H ( (.}V?TU&}'='=&> ?" " 	
 Jg.D&& /. ( +6==?
KC	K|I;a	9 
 
g	.@MM""	
 
/ 6;95EF5Er||F+5EOF
*?
KC	A 
 
g	.@MM""	
 
/ FK9EUEUv||A*"((;EU   +?
KC	>  
g	.@MM""	
 
/ HMYGWGW!v||A*"**=GW   +?
KC	) 
 
g	.@MM""	
 
/ +6!SbS&>
JC	" 
 
g	.@MM""	
 
/ mmF"((;O
*?
KC	6  
g	.@MM""	
 
/ +6C<
HC	O 
 
g	.@MM""	
 
/	.y /. 
/	. G 
/	. 
/	. 
/	. 
/	. 
/	. 
/	.sr   !M6!M!, M3$!M8<N
.!N$<N!8!N& !N8"!O
$!O
M	!
M08
N
N&
N58
O

O
O)c            
      f   Su  pn[        U SUSSSSS9u  p4XA* S  n " S S	[        5      nU" UR                  5       S
9nSn[        [        US9   [        UR                  R                  U5        S S S 5        U" US S 2S S24   S
9nSn[        [        US9   [        UR                  R                  U5        S S S 5        U" US
9nSn[        [        US9   [        UR                  R                  U5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N_= f! , (       d  f       g = f)Nr  rV  r  r  Tr   r  c                       \ rS rSrS rSrg)otest_check_classifiers_multilabel_output_format_decision_function.<locals>.MultiLabelClassifierDecisionFunctioni  c                     U R                   $ rj   r  rx   s     re   r  ځtest_check_classifiers_multilabel_output_format_decision_function.<locals>.MultiLabelClassifierDecisionFunction.decision_function  r  rd   r]   N)r^   r_   r`   ra   r  rc   r]   rd   re   $MultiLabelClassifierDecisionFunctionr    r  rd   r  r  zwMultiLabelClassifierDecisionFunction.decision_function is expected to output a NumPy array. Got <class 'list'> instead.r  r  zMultiLabelClassifierDecisionFunction.decision_function is expected to provide a NumPy array of shape \(n_samples, n_outputs\). Got \(25, 4\) instead of \(25, 5\)z^MultiLabelClassifierDecisionFunction.decision_function is expected to output a floating dtype.)r   r  r  r(   r  r0   r   r^   )	r  r  r  r  rn   r  r  r  r  s	            re   Atest_check_classifiers_multilabel_output_format_decision_functionr    s5   &0#I))DA z{^F(/L (
 /v}}
OC	@  
g	.DMM""	
 
/ /va"f~
NC	* 
 
g	.DMM""	
 
/ /v
FC	'  
g	.DMM""	
 
/	./ 
/	. 
/	. 
/	.s$   !D !D!D" 
D
D"
D0c                     [         R                  S   n [        U 5       Vs/ s H&  nUR                  S5      (       d  M  [	        X5      PM(     nnU Vs/ s H  n[
        R                  " U5      PM     nn[
        R                  " 5       nUR                  U5        [
        R                  " 5       nUR                  U5        gs  snf s  snf )z1Runs the tests in this file without using pytest.__main__test_N)sysmodulesdir
startswithgetattrunittestFunctionTestCase	TestSuiteaddTestsTextTestRunnerrun)main_moduler  test_functionsfnrS  suiterunners          re   run_tests_without_pytestr    s    ++j)K $$D??7# 	#"$  
 ;II.B(++B/.JI E	NN:$$&F
JJu
 Js   CC Cc                      Sn [        [        U S9   [        S[        5       5        S S S 5        g ! , (       d  f       g = f)NzIClassifier estimator_name is not computing class_weight=balanced properlyr  r|  )r(   r  r-   r$  r  s    re   2test_check_class_weight_balanced_linear_classifierr    s.    
UC	c	*5:<	
 
+	*	*r  c                      [         R                  " SS9 n [        5       nS S S 5        W (       a   eW H/  nUR                  R                  R                  S5      (       d  M/   e   g ! , (       d  f       NM= f)NTr  r  )r  r  r   r   r^   r  )r  
estimatorsrb  s      re   test_all_estimators_all_publicr    s_     
	 	 	-#%
 
. :==))44S9999 	 
.	-s   A''
A5r  c                  V   [        [        [        5      5      n [        U 5      n[	        U SUSS9n[        U5      S:  d   e/ nU H  u  pE U" U5        M     [        UR                  5       5      [        U5      ::  d   eg ! [         a    UR                  [        U5      5         Mb  f = f)NTskip)legacyr[  markr   )nextr!   r   r"   rP   rZ  r&   appendr)   r)  r*  )rb  r&  checksskipped_checksr#  checks         re   .test_estimator_checks_generator_skipping_testsr    s    
#E*
+C237'D1AF  1$$$N"		6) # $$&'3~+>>>>	  	6!!+e"45	6s   B  $B('B(c                  4   [        5       n [        U 5      n[        U5      S:  d   e[        R                  " SS9 n[        U USS9nSSS5        W Vs/ s H  oDR                  [        :w  d  M  UPM     nn[        U Vs/ s H  ofR                  [        :H  PM     sn5      (       d   e[        U5      [        U5      :X  d   eW Vs/ s H  owS   S:X  d  M  UPM     nn[        U5      [        U5      :X  d   eg! , (       d  f       N= fs  snf s  snf s  snf )	zTest that the right number of xfail warnings are raised when on_fail is "warn".

It also checks the number of raised EstimatorCheckFailedWarning, and checks the
output of check_estimator.
r   Tr  warn)r[  r   Nr"  xfail)
r   r"   rZ  r  r  r8   r  r   r7  r   )	rb  r[  r  logswxfail_warnsr  logxfaileds	            re   "test_xfail_count_with_no_fast_failr  3  s     'C8=%&***		 	 	-#9
 
. &Gg)F1gKG{S{ ;;{STTTT{s#9::::"?ds(mw&>sdG?w<356666 
.	- HS @s)   C:D.D?DDD:
Dc            	        ^ SSSSS.mU4S jn [        5       n[        U5      n[        U5      S:  d   e[        R                  " SS9   [        UUSU S9  SSS5        [        [        [        USS95      5      nTS	   [        U5      :X  d   eTS
   S:  d   eTS   S:X  d   eTS   UTS	   -
  TS
   -
  :X  d   eg! , (       d  f       Nl= f)z:Test that the callback is called with the right arguments.r   r  skippedr5  r1  c                 0   > US;   d   eTU==   S-  ss'   g )Nr  r   r]   )r#  r%  r$  r"  r&  r'  
call_counts         re   callback/test_check_estimator_callback.<locals>.callbackO  s$     AAAA6ard   Tr  N)r[  r   r  r  r  r5  r1  r  )r   r"   rZ  r  r  r8   r6  rP   )r  rb  r[  all_checks_countr  s       @re   test_check_estimator_callbackr  K  s    a1EJ  'C8=%&***		 	 	-#9		
 
. 4 :3t LMNg#&<"====h!###h1$$$i :g..H1EE   
.	-s   	B<<
C
c                      [         erj   )r&   r%   r$   r#   r8   )minimal_estimatorsr#  s     re   (test_minimal_class_implementation_checksr  r  s	     Nrd   c                       " S S[         5      n [        [        SS9   [        SU " SS95        S S S 5        [        SU " SS95        [        SU " S	S95        g ! , (       d  f       N/= f)
Nc                   B    \ rS rSrSS jrS r\" S 5      S 5       rSrg)	1test_check_fit_check_is_fitted.<locals>.Estimatori}  c                     Xl         g rj   behavior)rl   r  s     re   r   :test_check_fit_check_is_fitted.<locals>.Estimator.__init__~  s    $Mrd   c                 f    U R                   S:X  a	  SU l        U $ U R                   S:X  a  SU l        U $ )N	attributeTr  )r  
is_fitted_
_is_fitted)rl   rm   rn   r   s       re   ro   5test_check_fit_check_is_fitted.<locals>.Estimator.fit  s6    }}+"& K (*"&Krd   c                      U R                   S;   $ )N>   r  always-truer  rm  s    re   <lambda>:test_check_fit_check_is_fitted.<locals>.Estimator.<lambda>  s    4==4M#Mrd   c                 <    U R                   S:X  a  g[        U S5      $ )Nr  Tr  )r  r  rm  s    re   __sklearn_is_fitted__Gtest_check_fit_check_is_fitted.<locals>.Estimator.__sklearn_is_fitted__  s    }}-4..rd   )r  r  r  N)r  )	r^   r_   r`   ra   r   ro   rT   r  rc   r]   rd   re   ra  r  }  s'    	%	 
M	N	/ 
O	/rd   ra  z'passes check_is_fitted before being fitr  r#  r  r  r  r  )r   r(   	ExceptionrB   )ra  s    re   test_check_fit_check_is_fittedr  |  sZ    /M /" 
	!J	K!+y-/PQ 
L k9h+GHk9k+JK	 
L	Ks   A
A&c                       " S S[         5      n [        R                  " SS9 n[        SU " 5       5        S S S 5        W Vs/ s H  o"R                  PM     sn(       a   eg ! , (       d  f       N2= fs  snf )Nc                       \ rS rSrS rSrg)-test_check_requires_y_none.<locals>.Estimatori  c                     [        X5      u  pg rj   )rX   rk   s      re   ro   1test_check_requires_y_none.<locals>.Estimator.fit  s    Q?DAqrd   r]   Nr   r]   rd   re   ra  r    s    	#rd   ra  Tr  r#  )r   r  r  rM   message)ra  r  r   s      re   test_check_requires_y_noner    s]    #M # 
	 	 	-k9;7 
. $**6a		6****	 
.	- +s   A"A3"
A0c                  
   [         [        [        4 Hn  n [        [	        U " 5       SS95      n[
        U;   d   e[        U;   d   e " S SU 5      n[        [	        U" 5       SS95      n[
        U;  d   e[        U;  a  Mn   e   g )NTr  c                   (   ^  \ rS rSrU 4S jrSrU =r$ )@test_non_deterministic_estimator_skip_tests.<locals>.MyEstimatori  c                 2   > [         TU ]  5       nSUl        U$ r  )r   r  non_deterministicr  s     re   r  Qtest_non_deterministic_estimator_skip_tests.<locals>.MyEstimator.__sklearn_tags__  s    w/1)-&rd   r]   r^   r_   r`   ra   r  rc   r   r   s   @re   MyEstimatorr!    s     rd   r&  )r%   r$   r#   r6  r+   rD   rE   )ra  	all_testsr&  s      re   +test_non_deterministic_estimator_skip_testsr(    s     )*:<MN	*9;tDE	4	AAA.);;;	) 	 *;=FG	4IEEE.i??? Ord   c            
          " S S[         [        5      n U " 5       n[        UR                  R                  U5      b   e " S SU 5      nU" 5       nSn[        [        US9   [        UR                  R                  U5        SSS5        [        [        SS	S
S9/UR                  S'   U" 5       n[        UR                  R                  U5        [        [        SSS
S9[        [        SSS
S9[        [        SSS
S9[        [        SS	SS9/nSnU HQ  nU/UR                  S'   U" 5       n[        [        US9   [        UR                  R                  U5        SSS5        MS     g! , (       d  f       N= f! , (       d  f       Mv  = f)zHCheck the test for the contamination parameter in the outlier detectors.c                   6    \ rS rSrSrSS jrS	S jrS
S jrSrg)Jtest_check_outlier_contamination.<locals>.OutlierDetectorWithoutConstrainti  z.Outlier detector without parameter validation.c                     Xl         g rj   contamination)rl   r.  s     re   r   Stest_check_outlier_contamination.<locals>.OutlierDetectorWithoutConstraint.__init__  s    !.rd   Nc                     U $ rj   r]   )rl   rm   rn   r  s       re   ro   Ntest_check_outlier_contamination.<locals>.OutlierDetectorWithoutConstraint.fit      Krd   c                 H    [         R                  " UR                  S   5      $ rs   rt   rk   s      re   ry   Rtest_check_outlier_contamination.<locals>.OutlierDetectorWithoutConstraint.predict  s    771771:&&rd   r-  )g?r  rj   ra  r]   rd   re    OutlierDetectorWithoutConstraintr+    s    <	/		'rd   r5  Nc                   ,    \ rS rSrS\" S15      /0rSrg)Gtest_check_outlier_contamination.<locals>.OutlierDetectorWithConstrainti  r.  autor]   N)r^   r_   r`   ra   r    _parameter_constraintsrc   r]   rd   re   OutlierDetectorWithConstraintr7    s    "1Jx4H3I!Jrd   r:  zDcontamination constraints should contain a Real Interval constraint.r  r   g      ?right)closedr.  r   r  rV  leftz<contamination constraint should be an interval in \(0, 0.5\])r
   r   rH   r   r^   r(   r  r   r   r9  r   )r5  detectorr:  r  incorrect_intervalsintervals         re    test_check_outlier_contaminationrA    so   

'< 
' 01H&x'9'9'B'BHMUUUK(H K -.HTG	g	.#H$6$6$?$?J 
/
 	q#g.M!88I -.H 2 2 ; ;XF 	1a0r1W-q!G,q#f-	 NG'Q
%<<_M 12N'2'(:(:(C(CXN 32 (% 
/	.. 32s   !!E'9!E8'
E58
F	c                  .    [        SS9n [        SU 5        g)zCheck that in case with some probabilities ties, we relax the
ranking comparison with the decision function.
Non-regression test for:
https://github.com/scikit-learn/scikit-learn/issues/24025
log_loss)lossr   N)r   r5   )r#  s    re   test_decision_proba_tie_rankingrE    s     :.I$_i@rd   c                  >   [        5       n [        [        U SS95      n[        [        U SS95      n[        U5      [        U5      :  d   eS nU Vs1 s H
  oC" U5      iM     nnU Vs1 s H
  oC" U5      iM     nnUR	                  U5      (       d   eg s  snf s  snf )NTr  Fc                 h     U R                   $ ! [         a    U R                  R                   s $ f = frj   )r^   r<  func)r  s    re   get_check_name4test_yield_all_checks_legacy.<locals>.get_check_name  s0    	'>>! 	'::&&&	's     11)r#   r6  r+   rZ  issubset)r#  legacy_checksnon_legacy_checksrI  r  non_legacy_check_nameslegacy_check_namess          re   test_yield_all_checks_legacyrP    s    !#I*9TBCM.yGH}$5 6666' BSSARnU3ARS=JK]E./]K!**+=>>>> TKs   B)Bc                       " S S[         5      n U " 5       nSn[        [        US9   [        SU5        SSS5        g! , (       d  f       g= f)zICheck that the right error is raised when the estimator is not cloneable.c                       \ rS rSrS rSrg):test_check_estimator_cloneable_error.<locals>.NotCloneablei  c                     [        S5      e)Nz This estimator is not cloneable.NotImplementedErrorrm  s    re   __sklearn_clone__Ltest_check_estimator_cloneable_error.<locals>.NotCloneable.__sklearn_clone__  s    %&HIIrd   r]   N)r^   r_   r`   ra   rW  rc   r]   rd   re   NotCloneablerS    s    	Jrd   rY  zCloning of .* failed with errorr  N)r   r(   r  r9   )rY  r#  r  s      re   $test_check_estimator_cloneable_errorrZ  	  s>    J} J I
+C	c	*!.)< 
+	*	*	   =
Ac                       " S S[         5      n U " 5       nSn[        [        US9   [        SU5        SSS5        g! , (       d  f       g= f)zMCheck that the right error is raised when the estimator does not have a repr.c                       \ rS rSrS rSrg)*test_estimator_repr_error.<locals>.NotRepri  c                     [        S5      e)Nz$This estimator does not have a repr.rU  rm  s    re   __repr__3test_estimator_repr_error.<locals>.NotRepr.__repr__  s    %&LMMrd   r]   N)r^   r_   r`   ra   r`  rc   r]   rd   re   NotReprr^    s    	Nrd   rb  zRepr of .* failed with errorr  N)r   r(   r  r:   )rb  r#  r  s      re   test_estimator_repr_errorrc    s>    N- N 	I
(C	c	*Y	2 
+	*	*r[  c                  J    " S S5      n  " S S5      n " S S5      nSn[        [        US9   [        SU " 5       5        S S S 5        [        [        US9   [        SU" 5       5        S S S 5        [        SU" 5       5        g ! , (       d  f       NH= f! , (       d  f       N1= f)	Nc                       \ rS rSrS rSrg)8test_check_estimator_tags_renamed.<locals>.BadEstimator1i$  c                     g rj   r]   rm  s    re   
_more_tagsCtest_check_estimator_tags_renamed.<locals>.BadEstimator1._more_tags%      rd   r]   N)r^   r_   r`   ra   rh  rc   r]   rd   re   BadEstimator1rf  $      	rd   rk  c                       \ rS rSrS rSrg)8test_check_estimator_tags_renamed.<locals>.BadEstimator2i(  c                     g rj   r]   rm  s    re   	_get_tagsBtest_check_estimator_tags_renamed.<locals>.BadEstimator2._get_tags)  rj  rd   r]   N)r^   r_   r`   ra   rp  rc   r]   rd   re   BadEstimator2rn  (  rl  rd   rr  c                        \ rS rSrS rS rSrg)8test_check_estimator_tags_renamed.<locals>.OkayEstimatori,  c                     g rj   r]   rm  s    re   r  Itest_check_estimator_tags_renamed.<locals>.OkayEstimator.__sklearn_tags__-  rj  rd   c                     g rj   r]   rm  s    re   rh  Ctest_check_estimator_tags_renamed.<locals>.OkayEstimator._more_tags0  rj  rd   r]   N)r^   r_   r`   ra   r  rh  rc   r]   rd   re   OkayEstimatorrt  ,  s    		rd   ry  z.has defined either `_more_tags` or `_get_tags`r  )r(   r  r>   )rk  rr  ry  r  s       re   !test_check_estimator_tags_renamedrz  #  s{        ;C			%$_moF 
&			%$_moF 
& !-/B 
&	%	%	%s   BB
B
B"c                       " S S[         5      n Sn[        [        US9   [        SU " 5       5        SSS5        g! , (       d  f       g= f)zaCheck that when the estimator has the wrong tags.classifier_tags.multi_class
set, the test fails.c                       \ rS rSrS rSrg)Etest_check_classifier_not_supporting_multiclass.<locals>.BadEstimatoriC  c                     U $ rj   r]   rk   s      re   ro   Itest_check_classifier_not_supporting_multiclass.<locals>.BadEstimator.fitF  r2  rd   r]   Nr   r]   rd   re   BadEstimatorr}  C  s    	rd   r  z=The estimator tag `tags.classifier_tags.multi_class` is Falser  N)r   r(   r  r/   r  r  s     re   /test_check_classifier_not_supporting_multiclassr  ?  s8    }  JC	c	*2><>R 
+	*	*s	   ;
A	c                      S H<  n  [         R                  " U 5        [	        5       R                  U S9n[        U5        M>     g ! [         a    [        SU  S35      ef = f)N)r  polarszLibrary z is not installed)r:  )r  
__import__r  r&   r   
set_outputr8   )libr#  s     re   test_estimator_with_set_outputr  O  se    #	>  % #$//#/>		" $  	>XcU*;<==	>s   AAc                  N    [        [        5       5      n [        U 5      (       d   eg)z0Check that checks_generator returns a generator.N)rP   r   r   )all_instance_gen_checkss    re   test_estimator_checks_generatorr  [  s#    89K9MN.////rd   c                  |    [        [        SS9   [        [        5       SS S9  SSS5        g! , (       d  f       g= f)zMCheck that check_estimator fails correctly with on_fail='raise' and callback.z9callback cannot be provided together with on_fail='raise'r  raisec                      g rj   r]   r]   rd   re   r  Dtest_check_estimator_callback_with_fast_fail_error.<locals>.<lambda>f  s    PTrd   )r   r  N)r(   r   r8   r   r]   rd   re   2test_check_estimator_callback_with_fast_fail_errorr  a  s2    	U
 	*,gU
 
 
r  c                       " S S[         [        5      n Sn[        [        [        R
                  " U5      S9   [        SU " 5       5        SSS5        g! , (       d  f       g= f)zFTest that the check raises an error when the mixin order is incorrect.c                       \ rS rSrSS jrSrg),test_check_mixin_order.<locals>.BadEstimatoril  Nc                     U $ rj   r]   rk   s      re   ro   0test_check_mixin_order.<locals>.BadEstimator.fitm  r2  rd   r]   rj   r   r]   rd   re   r  r  l  s    	rd   r  z8TransformerMixin comes before/left side of BaseEstimatorr  N)r   r   r(   r  reescaperF   r  s     re   test_check_mixin_orderr  i  sC    }&6  EC	biin	5.,.9 
6	5	5s   A
A"c                       " S S[         5      n [        [        SS9   [        SU " 5       5        S S S 5        g ! , (       d  f       g = f)Nc                   (   ^  \ rS rSrU 4S jrSrU =r$ )Htest_check_positive_only_tag_during_fit.<locals>.RequiresPositiveXBadTagiv  c                 F   > [         TU ]  5       nSUR                  l        U$ r  )r   r  r  r  r  s     re   r  Ytest_check_positive_only_tag_during_fit.<locals>.RequiresPositiveXBadTag.__sklearn_tags__w  s!    7+-D,1DOO)Krd   r]   r%  r   s   @re   RequiresPositiveXBadTagr  v  s    	 	rd   r  z5This happens when passing negative input values as X.r  )r  r(   r  rK   )r  s    re   'test_check_positive_only_tag_during_fitr  u  sB    "<  
U
 	+%'>'@	

 
 
s	   9
A)r  r  r  r  r  inspectr   numbersr   r   r\  numpyru   scipy.sparser  r  sklearnr   r   sklearn.baser   r	   r
   r   sklearn.clusterr   sklearn.datasetsr   r   sklearn.decompositionr   sklearn.exceptionsr   r   r   sklearn.linear_modelr   r   r   r   sklearn.mixturer   sklearn.neighborsr   r.  r   sklearn.svmr   r   r/  r   r   r   sklearn.utils._param_validationr   r    -sklearn.utils._test_common.instance_generatorr!   r"   sklearn.utils._testingr#   r$   r%   r&   r'   r(   sklearn.utils.estimator_checksr)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   sklearn.utils.fixesrR   rS   sklearn.utils.metaestimatorsrT   sklearn.utils.multiclassrU   sklearn.utils.validationrV   rW   rX   rY   r   r[   rg   r}   r   r   r   r   r   r   r   r   r   r   r  r  r$  r4  r=  rE  rP  rc  rr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r  r9  r>  rC  rU  rX  rd  rf  r  r  r  r  r  r  r  r  r  r  r  r  r^   r  r  r  r  r  r  r(  rA  rE  rP  rZ  rc  rz  r  r  r  r  r  r  r]   rd   re   <module>r     s|  
  	 
    "    . W W + & 
  , 1 0 " @ @ @ * * * * * * * * * * *V @ 5 3 J # ##- # M  ] "= 	] 	 "= &( #* #(	#&7 	##] #(#4 , $- $ m *"#$5 "#J   F((- ("4] 4,} 5 "!1  
!1 
"4 	= 	'] '
0	L,R9I4"L	F
V<
E6!3H-,P^6,D	N+
\
R

L 
O] 
(XVy
x2
j
: z ?(70"N#L2	+@&3OlA?*
=
3C8S 	#0V	:
rd   