
    >[g6              	          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jN                         5   ejP                  de)       ejT                  jW                  e
jX                        gZ- e. ede-      D  cg c]  } d| d   v sd| d   v s| d    c}       Z/ddd       g dZ0g dZ1d Z2d Z3d Z4d Z5e	jl                  jo                  d      e	jl                  jq                  d e             d               Z9d Z:e!d        Z;e!d         Z<yc c} w # 1 sw Y   {xY w)!    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ignorezsklearn.)prefixpathz._   z.tests.)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 ]  }|j                  d      r|dk(  rt        j                  d	      5  t        j                  |      }d d d        t        j                  t        j                        }|D cg c]#  }|d
   j                  j                  d      s"|% }}|D ]8  \  }}g }|t        v s|j                  d      r#t        j                   |      r9t        j                  d	      5 }| j#                  |      }	d d d        t%              rt'        d|d|d|d         t)        |j*                        r|t-        |j.                  	      z  }|	j0                  D ]k  }
t3        ||
      }t)        |      rd }|
t4        v r5t7        |      }d|j8                  v r|j8                  d   j:                  dg}t-        ||      }||z  }m ||z  }; t        j                  |t        j<                        }|D cg c]  }|d
   j                  |k(  s| }}|D ]l  \  }}|j                  d      r|dk(  r|j                  d      r/t?        |      tA        fdt        D              rSt)        |      r_|t-        |      z  }n  djC                  |      }t%        |      dkD  rtE        d|z         y # 1 sw Y   xY wc c}w # 1 sw Y   xY wc c}w )Nnumpydocz+numpydoc is required to test the docstrings)reasonr   	docscrapez	.conftestzsklearn.utils.fixesT)recordr   sklearn_zError for __init__ of z in z:
y)r   configurationsetupc              3   &   K   | ]  }|v  
 y w)N ).0dname_s     b/var/www/html/bid-api/venv/lib/python3.12/site-packages/sklearn/tests/test_docstring_parameters.py	<genexpr>z,test_docstring_parameters.<locals>.<genexpr>   s     >+=aqEz+=s   
zDocstring Error:
)#pytestimportorskipr$   r'   PUBLIC_MODULESendswithwarningscatch_warnings	importlibimport_moduleinspect
getmembersisclass
__module__
startswith_DOCSTRING_IGNORES
isabstractClassDoclenRuntimeErrorr   __new__r   __init__methodsgetattr_METHODS_IGNORE_NONE_Yr   
parametersdefault
isfunctionr   anyjoinAssertionError)r'   	incorrectnamemoduleclassesclscnamethis_incorrectwcdocmethod_namemethodparam_ignoresigresult	functionsfnfnamefuncmsgr2   s                       @r3   test_docstring_parametersrf   M   s    H
 #I==%(($$D1,,T2F 2$$VW__=")U'3SV->->-I-I)-T3'U!JE3N**e.>.>s.C!!#&((5 ))#. 61v"=@$!M 
 ckk*8tLLN#|| k2!&)# "88#F+Ccnn,1D1L1L1T(+u3F<P&(  , 'IC "F &&vw/A/AB	"+H)Br!u/?/?4/GR)	H$KE4$'DMM',B"4(E>+=>>~H 7==	 %e | ))I
C
9~1C788 q 21 V 65> Is0   K/#K<K<L/LL/K9	Lc                 ,     | t               dddgi      S )NCg?r   r   )SearchCVs    r3   _construct_searchcv_instancerj      s    &(3a/::    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 y )NColumnTransformertransformerpassthroughr   r   )transformersPipelineclf)stepsFeatureUnion)transformer_list)__name__r   r   )	Estimators    r3   $_construct_compose_pipeline_instancerx      sy    00}q!f'M&NOO			z	)(:(< =>??			~	-M;N;P+Q*RSS 
.rk   c                 |    t        j                  g dg dg dg dg dgt         j                        } | |      S )N)r   r   r   )rz      )r   r   r   )r   r   r   )r   r{   r   )dtype)
dictionary)nparrayfloat64)rw   r}   s     r3   _construct_sparse_coderr      s2    	KIyAjjJ 
++rk   z-ignore::sklearn.exceptions.ConvergenceWarningzname, Estimatorc                    t        j                  d       ddlm} |j	                  |      }|d   }|j
                  dv rt        |      }n|j
                  dv rt        |      }np|j
                  dk(  rt        |      }nU|j
                  dk(  r2t        d	d
d      \  }} |t               j                  ||            }nt        t        |            }|j
                  dk(  r|j                  d       n|j
                  dk(  r|j                  d       n|j
                  dk(  s|j
                  j                  d      r|j                  d       nB|j
                  dv r|j                  d       n!|j
                  dk(  r|j                  d       d|j!                         v r3|j                  d       |j
                  dk(  r|j                  d       d|j!                         v r|j                  d       i }|j
                  j#                  d      r/|j
                  dv rg d }n|j
                  d!k(  r
ddd"d#dd$g}d }n+t        d	d#ddd%      \  }}t%        ||      }t'        ||      }|j)                         j*                  j,                  r|j                  |       n|j)                         j*                  j.                  r%|j                  t0        j2                  ||f          n\|j)                         j4                  j6                  r&|j                  t0        j8                  d&f   |       n|j                  |       |D ]q  }	|	j:                  |v rd'j=                  |	j>                        jA                         }
d(|
v r@tC        tD        )      5  tG        ||	j:                        sJ 	 d d d        s tI        |      }|D 	cg c]  }	|	j:                   }}	tK        |      jM                  |      }tK        |      jM                  |      }|rtO        d*|j
                   d+|       y # 1 sw Y   xY wc c}	w ),Nr$   r   r&   
Attributes)HalvingRandomSearchCVRandomizedSearchCVHalvingGridSearchCVGridSearchCV)rm   rq   rt   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 categoryzUndocumented attributes for z: )(r6   r7   r$   r'   rE   rv   rj   rx   r   r   r   r   nextr   
set_paramsrB   
get_paramsr9   r   r   __sklearn_tags__target_tagsone_d_labelstwo_d_labelsr~   c_
input_tagsthree_d_arraynewaxisrT   rQ   desclowerr   FutureWarninghasattr_get_all_fitted_attributesset
differencerR   )rT   rw   r'   doc
attributesestXr+   skipped_attributesattrr   fit_attrfit_attr_namesundocumented_attrss                 r3   test_fit_docstring_attributesr      s    
#"


Y
'C\"J   +95			   

 39=			}	,%i0			0	0"RAAN1*,00A67 '	23]*			0	0-			u	$	(:(:(E(Ee(LA&			   

 	A&			v	%!$ S^^%%"'NNCN())A& ""<0 "
 

A #331%q';<A"
1 &c1-%c1-
))66
					+	+	8	8ad					*	*	8	8"**c/"A&199**xx		"((* d?m43		*** 54  *#.H,67JDdiiJN7X11.A/0;;<NO*9+=+=*>bAS@TU
 	
  54 8s   &Q Q Q		c                 ,   t        | j                  j                               }t        j                         5  t        j
                  dt               t        | j                        D ]G  }t        | j                  |      }t        |t              s*	 t        | |       |j                  |       I 	 ddd       |D cg c](  }|j                  d      s|j                  d      r'|* c}S # t        t        f$ r Y w xY w# 1 sw Y   RxY wc c}w )zBGet all the fitted attributes of an estimator including propertieserrorr   Nr*   )list__dict__keysr:   r;   filterwarningsr   dir	__class__rK   
isinstancepropertyAttributeErrorappendr9   rB   )	estimatorr   rT   objr   s        r3   r   r   .  s     I&&++-.H 
	 	 	"-@	++,D)--t4Cc8,	4( OOD! - 
#   Mx!1::c?1<<;LAxMM	 #M2  
#	"  NsB   ADC0 D DD)D0D?DDDDc                     t         j                  t         j                  t         j                  t         j                  t         j
                  g} t        | dddg       d}t        | dgdj                  |j                                      y)	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   rQ   split)metrics_to_checkdescription_regexs     r3   3test_precision_recall_f_score_docstring_consistencyr   G  s     	// ! "?3	* 2 !!{HH%6%<%<%>?rk   c                  <    t        t        t        gg dddg       y)z?Check docstrings parameters stacking estimators are consistent.)cvn_jobsro   verboseTfinal_estimator_)r   include_attrsexclude_attrsN)r   r   r   r/   rk   r3   8test_stacking_classifier_regressor_docstring_consistencyr   x  s!     !	./A)*	rk   )=r<   r>   osr:   r   pkgutilr   numpyr~   r6   r)   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   r;   simplefilterr   r   dirname__file__sklearn_pathr   r8   rC   rL   rf   rj   rx   r   markr   parametrizer   r   r   r   )pckgs   0r3   <module>r      s     	   !     0 B 4 5 ( N  5 XH(M2GGOOG$4$456L &ZlK	
KDGOyDG'; GK	
N	   L9^;T, KL*N,<=v
 > Mv
rN2 - -`  S
	
 s   
AE-E(
,E-(E--E6