CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
test_common.cpython-310.pyc75 linesDownload Raw Back to __pycache__
1o

2�Yi]5�
@spdZddlZddlZddlZddlZddlmZddlmZddl	m3Z4ddlZddlm
Z
ddlZddlmZddlmZdd	lmZdd5lmZmZddlmZddlmZmZdd
lmZmZm Z m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8dd�Z9dVdd�Z:Gdd�de�Z;ej<�=dee:dd�dfe:dfee:d�dfedd�dfedd d!d"d#�d$fe;�d%fg�d&d'��Z>e8e?e'��e&d(�d)d*��Z@d+d,�ZAej<�Bd-�ej<�Bd.�d/d0���ZCd1d2�ZDd3d4�ZEd5d6�ZFd7d8�ZGe?e6e'�eedd��geG���ZHej<j=d9eHe%d:�d;d<��ZId=d>gZJd?d@�ZKdAdB�e'dC�D�ZLej<j=dCeLe%d:�dDdE��ZMdFdB�e'�D�ZNej<j=d9eNe%d:�dGdH��ZOej<j=d9e?e'��e%d:�dIdJ��ZPe?e7e'dC�ee!�e��e dKdL�edMdN�g��ZQej<j=d9eQe%d:�dOdP��ZRej<j=d9eQe%d:�ej<�=dQe4e/e5e0g�dRdS���ZSej<j=d9e'�e%d:�dTdU��ZTdS)Wz.8General tests for all estimators in sklearn.9�N)�partial)�isgenerator)�chain)�
LinAlgWarning)�
BaseEstimator)�ColumnTransformer)�ConvergenceWarning)�enable_halving_search_cv�enable_iterative_imputer)�LogisticRegression)�FeatureUnion�
make_pipeline)�FunctionTransformer�MinMaxScaler�
OneHotEncoder�StandardScaler)�all_estimators)�_get_check_estimator_ids�_get_expected_failed_checks�_tested_estimators)�SkipTest�ignore_warnings)
�(check_dataframe_column_names_consistency�check_estimator�!check_get_feature_names_out_error�$check_global_output_transform_pandas�(check_global_set_output_transform_polars�check_inplace_ensure_writeable�check_param_validation�check_set_output_transform�!check_set_output_transform_pandas�!check_set_output_transform_polars�'check_transformer_get_feature_names_out�.check_transformer_get_feature_names_out_pandas�parametrize_with_checkscCs4t�D]\}}d�|�}|���d�rJ|��qdS)NzDBase estimators such as {0} should not be included in all_estimators�base)r�format�lower�10startswith)�nameZ	Estimator�msg�r+��E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\sklearn/tests/test_common.py� test_all_estimator_no_base_class@s��r-�cC�dS�Nr+)�x�yr+r+r,�_sample_funcI�r3c@seZdZdZdd�ZdS)�CallableEstimatorzqDummy development stub for an estimator.11 12    This is to make sure a callable estimator passes common tests.13    cCr/r0r+)�selfr+r+r,�__call__Sr4zCallableEstimator.__call__N)�__name__�14__module__�__qualname__�__doc__r7r+r+r+r,r5Msr5z
val, expected)r2z_sample_func(y=1)Zworldg@)�CzLogisticRegression(C=2.0)z	newton-cgZbalancedT)Zrandom_stateZsolverZclass_weightZ15warm_startz]LogisticRegression(class_weight='balanced',random_state=1,solver='newton-cg',warm_start=True)zCallableEstimator()cCst|�|ksJ�dSr0)r)�val�expectedr+r+r,�test_get_check_estimator_idsWsr?)Zexpected_failed_checkscCs@tttttfd��
||�Wd�dS1swYdS�N��category)r�
FutureWarningr�UserWarningr)�	estimator�check�requestr+r+r,�test_estimatorsqs1617�18"�rHcCsLtjtdd��tt�dd�}Wd�n1swYt|�s$J�dS)zTCheck that check_estimator with generate_only=True raises a deprecation19    warning.z$`generate_only` is deprecated in 1.6��matchT)Z
generate_onlyN)�pytestZwarnsrCrrr)Zall_instance_gen_checksr+r+r,�.test_check_estimator_generate_only_deprecation}s��rLzZignore:Since version 1.0, it is not needed to import enable_hist_gradient_boosting anymorezGignore:Importing from sklearn.utils._estimator_html_repr is deprecated.cCs�tj�tj�g}tj|ddd�d�}dd�|D�}|dgD],}d|vs(d	|vr)qd20|vr.qt|dd�}t|d
d�D]}t	||�sIJd�21||���q:qdS)N�sklearn.cSr/r0r+��_r+r+r,�<lambda>��z-test_import_all_consistency.<locals>.<lambda>)�path�prefix�onerrorcSsg|]\}}}|�qSr+r+)�.0rO�modnamer+r+r,�22<listcomp>�sz/test_import_all_consistency.<locals>.<listcomp>�sklearnz.tests.zsklearn.externalszsklearn._build_utils�dummy)�fromlist�__all__r+z#Module '{0}' has no attribute '{1}')�osrR�dirnamerX�__file__�pkgutil�
walk_packages�23__import__�getattr�hasattrr&)�sklearn_pathZpkgsZsubmodsrV�packager)r+r+r,�test_import_all_consistency�s"	24����rfcCs`tj�tj�g}d}tj|dd�d�D]\}}}d|vs%|�d�s%||vr&q|tjvs-J�qdS)N)�utilsZtestsr%ZconftestcSr/r0r+rNr+r+r,rP�rQz3test_root_import_all_completeness.<locals>.<lambda>)rRrT�.rO)	r\rRr]rXr^r_r`r(r[)rdZ25EXCEPTIONSrOrVr+r+r,�!test_root_import_all_completeness�s��ricsnt�d��hd��tj�tj�g}dd�tj|dd�D�����fdd���	�D�}|gks5Jd	�26|���dS)27Nz�(?x)28                                      \.externals(\.|$)|29                                      \.tests(\.|$)|30                                      \._31                                      >zsklearn.datasets.descrzsklearn.datasets.datazsklearn.datasets.imagescSsi|]\}}}||�qSr+r+)rUrOr)�ispkgr+r+r,�32<dictcomp>�s��z1test_all_tests_are_importable.<locals>.<dictcomp>rM)rScs6g|]\}}|r|�vr��|�s|d�vr|�qS)z.tests)�search)rUr)rj�ZHAS_TESTS_EXCEPTIONS�lookupZresource_modulesr+r,rW�s���z1test_all_tests_are_importable.<locals>.<listcomp>zn{0} do not have `tests` subpackages. Perhaps they require __init__.py or a meson.build in the parent directory)�re�compiler\rRr]rXr^r_r`�itemsr&)rdZ
missing_testsr+rmr,�test_all_tests_are_importable�s���33�rrcCsxd}tjt|d��tt�Wd�n1swYtjt|d��ttg�Wd�dS1s5wYdS)Nz8Passing a class was deprecated.* isn't supported anymorerI)rKZraises�	TypeErrorrrr$�r*r+r+r,�test_class_support_removed�s34�"�ruccs��t�D]C}t|���}d|vr|jddd�Vqd|vr<|jddd�}|jjdvr8tj|tjj	dd	�d35�Vq|Vqd|vrG|jdd�VqdS)
N�	oob_scoreT)rvZ	bootstrap�early_stoppingr.)rw�n_iter_no_change>Z
MLPClassifierZMLPRegressorzMLP still validates in fitrt)Zmarksrx)rx)36r�set�37get_params�38set_params�	__class__r8rK�param�markZxfail)rEZ39est_params�estr+r+r,�_estimators_that_predict_in_fit�s �4041���r�rE)Zidsc	Cs�t|t�r42t�d�dt|�vrt�d�ttd��4tjdd��}t	|j43j|�Wd�n1s3wY|D]}dt|j
�vsEJ�q:Wd�dS1sQwYdS)Nz$ColumnTransformer is not tested hererzCEstimator does not support check_dataframe_column_names_consistencyrAT)�recordz was fitted without feature names)�44isinstancerrK�skiprrrC�warnings�catch_warningsrr|r8�str�message)rEr��warningr+r+r,�#test_pandas_column_name_consistency�s$4546�����"�r�ZensembleZkernel_approximationcCs&t|d�rdS|j�d�d}|tvS)N�get_feature_names_outTrhr.)rcr9�split�"GET_FEATURES_OUT_MODULES_TO_IGNORE)�transformer�moduler+r+r,�'_include_in_get_feature_names_out_checks47r�cCsg|]}t|�r|�qSr+)r��rUrr+r+r,rW#s��rWr�cCsLttd��t|jj|�t|jj|�Wd�dS1swYdSr@)rrCr"r|r8r#)r�r+r+r,�'test_transformers_get_feature_names_out*s��"�r�cCsg|]	}t|d�r|�qS)r�)rcr�r+r+r,rW7s4849��cCs|jj}t||�dSr0)r|r8r)rEZestimator_namer+r+r,�+test_estimators_get_feature_names_out_error<sr�cCs*t|t�r50t�d�|jj}t||�dS)NzFeatureUnion is not tested here)r�rrKr�r|r8r�rEr)r+r+r,�test_check_param_validationDs5152r�F)Z
sparse_outputz53one-to-one)Zfeature_names_outcCsb|jj}t|d�st�d|�d��ttd��t|jj|�Wd�dS1s*wYdS)N�54set_outputz(Skipping check_set_output_transform for z!: Does not support set_output APIrA)r|r8rcrKr�rrCrr�r+r+r,�test_set_output_transformZs5556�"�r��57check_funccCsj|jj}t|d�st�d|j�d|�d��ttd��||jj|�Wd�dS1s.wYdS)Nr�z	Skipping z for z%: Does not support set_output API yetrA)r|r8rcrKr�rrC)rEr�r)r+r+r,�$test_set_output_transform_configuredhs
58�"�r�cCs�|jj}t|d�r|jdd�nt|d�r|jdd�nt|�d���|dkr.|jdd	d59�|dkr8|jdd
�|dkrB|jdd�t||�dS)N�copyF)r��copy_X)r�z! doesn't require writeable input.ZHDBSCANZprecomputedZbrute)Zmetric�	algorithmZPCA�full)Z60svd_solverZ	KernelPCA)Zkernel)r|r8rcr{rrr�r+r+r,�#test_check_inplace_ensure_writeables6162r�)r.)Ur;r\r_ror��	functoolsr�inspectr�	itertoolsrrKZscipy.linalgrrXZsklearn.baserZsklearn.composerZsklearn.exceptionsrZsklearn.experimentalr	r63Zsklearn.linear_modelrZsklearn.pipelinerr
Zsklearn.preprocessingrrrrZ
sklearn.utilsrZ-sklearn.utils._test_common.instance_generatorrrrZsklearn.utils._testingrrZsklearn.utils.estimator_checksrrrrrrrrr r!r"r#r$r-r3r5r~Zparametrizer?�listrHrL�filterwarningsrfrirrrur�Zcolumn_name_estimatorsr�r�r�ZGET_FEATURES_OUT_ESTIMATORSr�Z%ESTIMATORS_WITH_GET_FEATURE_NAMES_OUTr�r�ZSET_OUTPUT_ESTIMATORSr�r�r�r+r+r+r,�<module>s�<64	65����6667�68	69��&��	�70���7172��73�74����75���	�
Aluode/PerceptionLabPortable · CoolFace