
    0Ph6                        d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlZd dl	Z	d dl
Z
d dl
mZ d dlmZ d dlmZmZ d dlmZm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mZmZm Z m!Z! d dl"m#Z# d dl$m%Z%m&Z&  ej'                    5   ej(        de)           ej*        +                    e
j,                  gZ- e.d  ede-          D                       Z/ddd           n# 1 swxY w Y   g dZ0g dZ1d Z2d Z3d Z4d Z5e	j6        7                    d          e	j6        8                    d e                      d                         Z9d Z:e!d             Z;e!d             Z<dS )    N)	signature)walk_packages)metrics)make_classification)StackingClassifierStackingRegressor)enable_halving_search_cvenable_iterative_imputerLogisticRegression)FunctionTransformer)all_estimators)_construct_instances)_get_func_nameassert_docstring_consistencycheck_docstring_parametersignore_warningsskip_if_no_numpydoc)_is_deprecated)_enforce_estimator_tags_X_enforce_estimator_tags_yignorec                 F    g | ]}d |d         v d|d         v |d         S )z._   z.tests. ).0pckgs     g/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/tests/test_docstring_parameters.py
<listcomp>r   0   sA     	
 	
 	
DGOOyDG';'; G';';';    zsklearn.)prefixpath)z%sklearn.utils.deprecation.load_mlcompzsklearn.pipeline.make_pipelinezsklearn.pipeline.make_unionz%sklearn.utils.extmath.safe_sparse_dotzsklearn.utils._joblibHalfBinomialLoss)fitscorefit_predictfit_transformpartial_fitpredictc                     t          j        dd           ddlm}  g }t          D ]                    d          rdk    r t          j        d	          5  t          j	                  }d d d            n# 1 swxY w Y   t          j        |t          j                  }d
 |D             }|D ]U\  }}g }|t          v s|                    d          r't          j        |          r<t          j        d	          5 }|                     |          }d d d            n# 1 swxY w Y   t#          |          rt%          d|dd|d                   t'          |j                  r|t+          |j        |          z  }|j        D ]p}	t1          ||	          }
t'          |
          r"d }|	t2          v r-t5          |
          }d|j        v r|j        d         j        dg}t+          |
|          }||z  }q||z  }Wt          j        |t          j                  }fd|D             }|D ]\  }}|                    d          r|dk    r                    d          r7t=          |          t?          fdt          D                       s!t'          |          s|t+          |          z  }d                     |          }t#          |          dk    rtC          d|z             d S )Nnumpydocz+numpydoc is required to test the docstrings)reasonr   	docscrapez	.conftestzsklearn.utils.fixesT)recordc                 R    g | ]$}|d          j                             d          "|%S )r   sklearn)
__module__
startswith)r   clss     r   r   z-test_docstring_parameters.<locals>.<listcomp>d   s2    UUU3SV->-I-I)-T-TU3UUUr    _zError for __init__ of z in z:
y)r   c                 6    g | ]}|d          j         k    |S )r   )r2   )r   fnnames     r   r   z-test_docstring_parameters.<locals>.<listcomp>   s*    HHHBr!u/?4/G/GR/G/G/Gr    configurationsetupc              3       K   | ]}|v V  	d S )Nr   )r   dname_s     r   	<genexpr>z,test_docstring_parameters.<locals>.<genexpr>   s'      >>aqEz>>>>>>r    
zDocstring Error:
)"pytestimportorskipr+   r.   PUBLIC_MODULESendswithwarningscatch_warnings	importlibimport_moduleinspect
getmembersisclass_DOCSTRING_IGNORESr3   
isabstractClassDoclenRuntimeErrorr   __new__r   __init__methodsgetattr_METHODS_IGNORE_NONE_Yr   
parametersdefault
isfunctionr   anyjoinAssertionError)r.   	incorrectmoduleclassescnamer4   this_incorrectwcdocmethod_namemethodparam_ignoresigresult	functionsfnamefuncmsgr9   r>   s                     @@r   test_docstring_parametersrl   M   s    H   
 #"""""I <> <>==%% 	((($D111 	3 	3,T22F	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3$VW_==UU'UUU! !	( !	(JE3N***e.>.>s.C.C*!#&& (555 / ))#../ / / / / / / / / / / / / / /1vv "l=@SS$$$!M  
 ck** 8tLLLN#| ) ) k22!&)) # "888#F++Ccn,,1D1L1T(+u3F<PPP&('II&vw/ABB	HHHH)HHH	$ 
	> 
	>KE4$$ ''DMM',B,B'"4((E>>>>+=>>>>> >~H H > 7===	
	> ))I

C
9~~1C7888 s$   A>>B	B	D))D-0D-c                 :     | t                      dddgi          S )NCg?r   r   )SearchCVs    r   _construct_searchcv_instancerp      s#    8&((3a/:::r    c                     | j         dk    r | ddddgfg          S | j         dk    r | dt                      fg	          S | j         d
k    r | dt                      fg          S d S )NColumnTransformertransformerpassthroughr   r   )transformersPipelineclf)stepsFeatureUnion)transformer_list)__name__r   r   )	Estimators    r   $_construct_compose_pipeline_instancer}      s    000y}q!f'M&NOOOO		z	)	)y(:(<(< =>????		~	-	-yM;N;P;P+Q*RSSSS 
.	-r    c                 x    t          j        g dg dg dg dg dgt           j                  } | |          S )N)r   r   r   )r      )r   r   r   )r   r   r   )r   r   r   )dtype)
dictionary)nparrayfloat64)r|   r   s     r   _construct_sparse_coderr      sT    	KKKIIIyyyAj  J 9
++++r    z-ignore::sklearn.exceptions.ConvergenceWarningzname, Estimatorc                    t          j        d           ddlm} |                    |          }|d         }|j        dv rt          |          }n|j        dv rt          |          }n|j        dk    rt          |          }nh|j        dk    rAt          d	d
d          \  }} |t                                          ||                    }nt          t          |                    }|j        dk    r|                    d           n|j        dk    r|                    d           n}|j        dk    s|j                            d          r|                    d           nA|j        dv r|                    d           n!|j        dk    r|                    d           d|                                v r7|                    d           |j        dk    r|                    d           d|                                v r|                    d           i }|j                            d          r&|j        dv rg d }n|j        d!k    r
ddd"d#dd$g}d }n7t          d	d#ddd%          \  }}t%          ||          }t'          ||          }|                                j        j        r|                    |           n|                                j        j        r(|                    t0          j        ||f                    n]|                                j        j        r)|                    |t0          j        d&f         |           n|                    ||           |D ]}	|	j        |v rd'                    |	j                                                   }
d(|
v r=tC          tD          )          5  tG          ||	j                  sJ 	 d d d            n# 1 swxY w Y   tI          |          }d* |D             }tK          |          &                    |          }tK          |          &                    |          }|rtO          d+|j         d,|           d S )-Nr+   r   r-   
Attributes)HalvingRandomSearchCVRandomizedSearchCVHalvingGridSearchCVGridSearchCV)rr   rv   ry   SparseCoderFrozenEstimator      )	n_samples
n_featuresrandom_stateSelectKBestr   )kDummyClassifier
stratified)strategyCCAPLSr   )n_components)GaussianRandomProjectionSparseRandomProjectionTSNE)
perplexitymax_iter)r      r   )r   
Vectorizer)CountVectorizerHashingVectorizerTfidfVectorizer)zThis is the first document.z%This document is the second document.zAnd this is the third one.zIs this the first document?DictVectorizer)foobar   )r   baz)r   r   n_redundant	n_classesr   . zonly categoryc                     g | ]	}|j         
S r   )r9   )r   attrs     r   r   z1test_fit_docstring_attributes.<locals>.<listcomp>%  s    777Ddi777r    zUndocumented attributes for z: )(rA   rB   r+   r.   rN   r{   rp   r}   r   r   r   r$   nextr   
set_paramsr3   
get_paramsrD   r   r   __sklearn_tags__target_tagsone_d_labelstwo_d_labelsr   c_
input_tagsthree_d_arraynewaxisr9   rZ   desclowerr   FutureWarninghasattr_get_all_fitted_attributesset
differencer[   )r9   r|   r.   doc
attributesestXr6   skipped_attributesr   r   fit_attrfit_attr_namesundocumented_attrss                 r   test_fit_docstring_attributesr      s7    
###""""""


Y
'
'C\"J    +955		   
 

 39==		}	,	,%i00		0	0	0"RAANNN1i*,,00A6677 '	2233]**		0	0	0----		u	$	$	(:(E(Ee(L(L	$A&&&&		   
 

 	A&&&&		v	%	%!$$$ S^^%%%%"""''NNCN((())))A&&& ""<00 . "
 
 

  AA #3331%%q';';<A"
 
 
1 &c1--%c1--
)6 



						+	8 ad						*	8 "*c/"A&&&&1 + +9***xx	""((** d??m444 	+ 	+3	******	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ *#..H77J777NX11.AA/00;;<NOO 
U9+=UUASUU
 
 	

 
s   O00O4	7O4	c                    t          | j                                                  }t          j                    5  t          j        dt                     t          | j                  D ]k}t          | j        |          }t          |t                    s-	 t          | |           n# t          t          f$ r Y Rw xY w|                    |           l	 ddd           n# 1 swxY w Y   d |D             S )zBGet all the fitted attributes of an estimator including propertieserrorr   Nc                 f    g | ].}|                     d           |                    d           ,|/S )r5   )rD   r3   )r   r   s     r   r   z._get_all_fitted_attributes.<locals>.<listcomp>D  s8    MMM!1::c??M1<<;L;LMAMMMr    )list__dict__keysrE   rF   filterwarningsr   dir	__class__rT   
isinstancepropertyAttributeErrorappend)	estimatorr   r9   objs       r   r   r   .  sK    I&++--..H 
	 	"	" " "-@@@@	+,, 	" 	"D)-t44Cc8,, 	4(((("M2   OOD!!!!	"" " " " " " " " " " " " " " "  NMxMMMMs6   AC#B)(C#)B=:C#<B==C##C'*C'c                     t           j        t           j        t           j        t           j        t           j        g} t          | dddg           d}t          | dgd                    |                                                     dS )	z>Check docstrings parameters of related metrics are consistent.Taveragezero_division)include_paramsexclude_paramsa  This parameter is required for multiclass/multilabel targets\.
        If ``None``, the metrics for each class are returned\. Otherwise, this
        determines the type of averaging performed on the data:
        ``'binary'``:
            Only report results for the class specified by ``pos_label``\.
            This is applicable only if targets \(``y_\{true,pred\}``\) are binary\.
        ``'micro'``:
            Calculate metrics globally by counting the total true positives,
            false negatives and false positives\.
        ``'macro'``:
            Calculate metrics for each label, and find their unweighted
            mean\.  This does not take label imbalance into account\.
        ``'weighted'``:
            Calculate metrics for each label, and find their average weighted
            by support \(the number of true instances for each label\)\. This
            alters 'macro' to account for label imbalance; it can result in an
            F-score that is not between precision and recall\.[\s\w]*\.*
        ``'samples'``:
            Calculate metrics for each instance, and find their average \(only
            meaningful for multilabel classification where this differs from
            :func:`accuracy_score`\)\.r   )r   descr_regex_patternN)	r   precision_recall_fscore_supportf1_scorefbeta_scoreprecision_scorerecall_scorer   rZ   split)metrics_to_checkdescription_regexs     r   3test_precision_recall_f_score_docstring_consistencyr   G  s     	/ ! "?3   	* 2 !!{HH%6%<%<%>%>??     r    c                  J    t          t          t          gg dddg           dS )z?Check docstrings parameters stacking estimators are consistent.)cvn_jobsrt   verboseTfinal_estimator_)r   include_attrsexclude_attrsN)r   r   r   r   r    r   8test_stacking_classifier_regressor_docstring_consistencyr   x  s@     !	./AAA)*	     r    )=rG   rI   osrE   r   pkgutilr   numpyr   rA   r1   r   sklearn.datasetsr   sklearn.ensembler   r   sklearn.experimentalr	   r
   sklearn.linear_modelr   sklearn.preprocessingr   sklearn.utilsr   -sklearn.utils._test_common.instance_generatorr   sklearn.utils._testingr   r   r   r   r   sklearn.utils.deprecationr   sklearn.utils.estimator_checksr   r   rF   simplefilterr   r"   dirname__file__sklearn_pathr   rC   rL   rU   rl   rp   r}   r   markr   parametrizer   r   r   r   r   r    r   <module>r     s        				        ! ! ! ! ! !             0 0 0 0 0 0 B B B B B B B B        4 3 3 3 3 3 5 5 5 5 5 5 ( ( ( ( ( ( N N N N N N              5 4 4 4 4 4        X 
 
H(M222GOOG$4556LS	
 	
%ZlKKK	
 	
 	
 N	
 
 
 
 
 
 
 
 
 
 
 
 
 
 
      L9 L9 L9^; ; ;T T T, , , KLL*NN,<,<==v
 v
 >= MLv
rN N N2 - - -`     s   AC&&C*-C*