From 4f1a8d52ae38b37cce6905d86b0735b1d9a0fc2c Mon Sep 17 00:00:00 2001 From: aboughammoura Date: Thu, 12 Jan 2023 18:36:21 +0100 Subject: [PATCH 1/3] contribution fastica --- Ahmed.ipynb | 73 ++++++++++++++++++++++++++ sklearn/decomposition/_fastica.py | 17 ++++-- sklearn/tests/test_public_functions.py | 1 + 3 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 Ahmed.ipynb diff --git a/Ahmed.ipynb b/Ahmed.ipynb new file mode 100644 index 0000000000000..d60b49da1e41c --- /dev/null +++ b/Ahmed.ipynb @@ -0,0 +1,73 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "ename": "ImportError", + "evalue": "No module named 'sklearn.__check_build._check_build'\n___________________________________________________________________________\nContents of /home/ahmed/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build:\n_check_build.c __pycache__ _check_build.pyx\n_check_build.cpython-39-x86_64-linux-gnu.so__init__.py\n___________________________________________________________________________\nIt seems that scikit-learn has not been built correctly.\n\nIf you have installed scikit-learn from source, please do not forget\nto build the package before using it: run `python setup.py install` or\n`make` in the source directory.\n\nIf you have used an installer, please check that it is suited for your\nPython version, your operating system and your platform.", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 47\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 48\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0m_check_build\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcheck_build\u001b[0m \u001b[0;31m# noqa\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 49\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'sklearn.__check_build._check_build'", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m/tmp/ipykernel_41355/2440152408.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0msklearn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0;31m# it and importing it first would fail if the OpenMP dll cannot be found.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0m_distributor_init\u001b[0m \u001b[0;31m# noqa: F401\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0m__check_build\u001b[0m \u001b[0;31m# noqa: F401\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0mbase\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mclone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_show_versions\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mshow_versions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0m_check_build\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcheck_build\u001b[0m \u001b[0;31m# noqa\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 49\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 50\u001b[0;31m \u001b[0mraise_build_error\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build/__init__.py\u001b[0m in \u001b[0;36mraise_build_error\u001b[0;34m(e)\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0mdir_content\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"\\n\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 31\u001b[0;31m raise ImportError(\n\u001b[0m\u001b[1;32m 32\u001b[0m \"\"\"%s\n\u001b[1;32m 33\u001b[0m \u001b[0m___________________________________________________________________________\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mImportError\u001b[0m: No module named 'sklearn.__check_build._check_build'\n___________________________________________________________________________\nContents of /home/ahmed/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build:\n_check_build.c __pycache__ _check_build.pyx\n_check_build.cpython-39-x86_64-linux-gnu.so__init__.py\n___________________________________________________________________________\nIt seems that scikit-learn has not been built correctly.\n\nIf you have installed scikit-learn from source, please do not forget\nto build the package before using it: run `python setup.py install` or\n`make` in the source directory.\n\nIf you have used an installer, please check that it is suited for your\nPython version, your operating system and your platform." + ] + } + ], + "source": [ + "import sklearn" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sklearn/decomposition/_fastica.py b/sklearn/decomposition/_fastica.py index bb0c4ccdd78ea..01de7e6da9d63 100644 --- a/sklearn/decomposition/_fastica.py +++ b/sklearn/decomposition/_fastica.py @@ -155,11 +155,20 @@ def _cube(x, fun_args): @validate_params( - { + { "X": ["array-like"], - "return_X_mean": ["boolean"], - "compute_sources": ["boolean"], - "return_n_iter": ["boolean"], + "n_components": [Interval(Integral, 1, None), None], + "algorithm":[StrOptions({'parallel', 'deflation'})], + "whiten":["boolean"], + "fun":[StrOptions({'logcosh', 'exp', 'cube'})], + "fun_args": [dict, None], + "max_iter": [Interval(Integral, 1, None)], + "tol": [Interval(Real, 0.0, None,), None], + "w_init": ["ndarray"], + "random_state":[Interval(Integral, 1, None), None], + "return_X_mean":["boolean"], + "compute_sources":["boolean"], + "return_n_iter":["boolean"], } ) def fastica( diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index 33760e1644e24..f4f4d9433d818 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -103,6 +103,7 @@ def _check_function_param_validation( "sklearn.datasets.fetch_california_housing", "sklearn.datasets.make_sparse_coded_signal", "sklearn.decomposition.sparse_encode", + "sklearn.decomposition.fastica", "sklearn.feature_extraction.grid_to_graph", "sklearn.feature_extraction.img_to_graph", "sklearn.feature_extraction.image.extract_patches_2d", From 5343e4f5b58e45c9bffcc60c43571e155863a36c Mon Sep 17 00:00:00 2001 From: aboughammoura Date: Thu, 12 Jan 2023 19:24:50 +0100 Subject: [PATCH 2/3] contribution spectral --- Ahmed.ipynb | 73 -------------------------- sklearn/cluster/_spectral.py | 16 ++++++ sklearn/tests/test_public_functions.py | 1 + 3 files changed, 17 insertions(+), 73 deletions(-) delete mode 100644 Ahmed.ipynb diff --git a/Ahmed.ipynb b/Ahmed.ipynb deleted file mode 100644 index d60b49da1e41c..0000000000000 --- a/Ahmed.ipynb +++ /dev/null @@ -1,73 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "ename": "ImportError", - "evalue": "No module named 'sklearn.__check_build._check_build'\n___________________________________________________________________________\nContents of /home/ahmed/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build:\n_check_build.c __pycache__ _check_build.pyx\n_check_build.cpython-39-x86_64-linux-gnu.so__init__.py\n___________________________________________________________________________\nIt seems that scikit-learn has not been built correctly.\n\nIf you have installed scikit-learn from source, please do not forget\nto build the package before using it: run `python setup.py install` or\n`make` in the source directory.\n\nIf you have used an installer, please check that it is suited for your\nPython version, your operating system and your platform.", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 47\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 48\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0m_check_build\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcheck_build\u001b[0m \u001b[0;31m# noqa\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 49\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'sklearn.__check_build._check_build'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/tmp/ipykernel_41355/2440152408.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0msklearn\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0;31m# it and importing it first would fail if the OpenMP dll cannot be found.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 80\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0m_distributor_init\u001b[0m \u001b[0;31m# noqa: F401\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 81\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0m__check_build\u001b[0m \u001b[0;31m# noqa: F401\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 82\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0mbase\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mclone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0mutils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_show_versions\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mshow_versions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;34m.\u001b[0m\u001b[0m_check_build\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcheck_build\u001b[0m \u001b[0;31m# noqa\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 49\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 50\u001b[0;31m \u001b[0mraise_build_error\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build/__init__.py\u001b[0m in \u001b[0;36mraise_build_error\u001b[0;34m(e)\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0mdir_content\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"\\n\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 31\u001b[0;31m raise ImportError(\n\u001b[0m\u001b[1;32m 32\u001b[0m \"\"\"%s\n\u001b[1;32m 33\u001b[0m \u001b[0m___________________________________________________________________________\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mImportError\u001b[0m: No module named 'sklearn.__check_build._check_build'\n___________________________________________________________________________\nContents of /home/ahmed/Desktop/ITI/ITI5/APPC/projet/scikit-learn/sklearn/__check_build:\n_check_build.c __pycache__ _check_build.pyx\n_check_build.cpython-39-x86_64-linux-gnu.so__init__.py\n___________________________________________________________________________\nIt seems that scikit-learn has not been built correctly.\n\nIf you have installed scikit-learn from source, please do not forget\nto build the package before using it: run `python setup.py install` or\n`make` in the source directory.\n\nIf you have used an installer, please check that it is suited for your\nPython version, your operating system and your platform." - ] - } - ], - "source": [ - "import sklearn" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.6" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/sklearn/cluster/_spectral.py b/sklearn/cluster/_spectral.py index 25f5ee7f9453c..0d6c13d66d427 100644 --- a/sklearn/cluster/_spectral.py +++ b/sklearn/cluster/_spectral.py @@ -21,6 +21,8 @@ from ..neighbors import kneighbors_graph, NearestNeighbors from ..manifold import spectral_embedding from ._kmeans import k_means +from ..utils._param_validation import Hidden, Interval, StrOptions, validate_params + def cluster_qr(vectors): @@ -191,6 +193,20 @@ def discretize( return labels + +@validate_params( + { + "affinity": ["array-like", "sparse matrix"], + "n_clusters": [Interval(Integral, 1, None), None], + "n_components": [Interval(Integral, 1, None), None], + "eigen_solver":[StrOptions({'arpack', 'lobpcg', 'amg', None})], + "random_state":[Interval(Integral, 1, None), None], + "n_init": [Interval(Integral, 1, None), None], + "eigen_tol": [Interval(Real, 0.0, None,), None], + "assign_labels":[StrOptions({'kmeans', 'discretize', 'cluster_qr'})], + "verbose": ["boolean"], + } +) def spectral_clustering( affinity, *, diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index f4f4d9433d818..90231cfd0c8bc 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -98,6 +98,7 @@ def _check_function_param_validation( "sklearn.cluster.compute_optics_graph", "sklearn.cluster.estimate_bandwidth", "sklearn.cluster.kmeans_plusplus", + "sklearn.cluster.spectral" "sklearn.covariance.empirical_covariance", "sklearn.covariance.shrunk_covariance", "sklearn.datasets.fetch_california_housing", From dbf320e996c37d7730103de32e923e9130384bae Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Tue, 24 Jan 2023 18:35:26 +0100 Subject: [PATCH 3/3] cleanup --- sklearn/cluster/_spectral.py | 19 ++----------------- sklearn/decomposition/_fastica.py | 17 ++++------------- sklearn/tests/test_public_functions.py | 3 +-- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/sklearn/cluster/_spectral.py b/sklearn/cluster/_spectral.py index 0d6c13d66d427..c10d402d27f42 100644 --- a/sklearn/cluster/_spectral.py +++ b/sklearn/cluster/_spectral.py @@ -15,14 +15,12 @@ from scipy.sparse import csc_matrix from ..base import BaseEstimator, ClusterMixin -from ..utils._param_validation import Interval, StrOptions +from ..utils._param_validation import Interval, StrOptions, validate_params from ..utils import check_random_state, as_float_array from ..metrics.pairwise import pairwise_kernels, KERNEL_PARAMS from ..neighbors import kneighbors_graph, NearestNeighbors from ..manifold import spectral_embedding from ._kmeans import k_means -from ..utils._param_validation import Hidden, Interval, StrOptions, validate_params - def cluster_qr(vectors): @@ -193,20 +191,7 @@ def discretize( return labels - -@validate_params( - { - "affinity": ["array-like", "sparse matrix"], - "n_clusters": [Interval(Integral, 1, None), None], - "n_components": [Interval(Integral, 1, None), None], - "eigen_solver":[StrOptions({'arpack', 'lobpcg', 'amg', None})], - "random_state":[Interval(Integral, 1, None), None], - "n_init": [Interval(Integral, 1, None), None], - "eigen_tol": [Interval(Real, 0.0, None,), None], - "assign_labels":[StrOptions({'kmeans', 'discretize', 'cluster_qr'})], - "verbose": ["boolean"], - } -) +@validate_params({"affinity": ["array-like", "sparse matrix"]}) def spectral_clustering( affinity, *, diff --git a/sklearn/decomposition/_fastica.py b/sklearn/decomposition/_fastica.py index 01de7e6da9d63..bb0c4ccdd78ea 100644 --- a/sklearn/decomposition/_fastica.py +++ b/sklearn/decomposition/_fastica.py @@ -155,20 +155,11 @@ def _cube(x, fun_args): @validate_params( - { + { "X": ["array-like"], - "n_components": [Interval(Integral, 1, None), None], - "algorithm":[StrOptions({'parallel', 'deflation'})], - "whiten":["boolean"], - "fun":[StrOptions({'logcosh', 'exp', 'cube'})], - "fun_args": [dict, None], - "max_iter": [Interval(Integral, 1, None)], - "tol": [Interval(Real, 0.0, None,), None], - "w_init": ["ndarray"], - "random_state":[Interval(Integral, 1, None), None], - "return_X_mean":["boolean"], - "compute_sources":["boolean"], - "return_n_iter":["boolean"], + "return_X_mean": ["boolean"], + "compute_sources": ["boolean"], + "return_n_iter": ["boolean"], } ) def fastica( diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index 90231cfd0c8bc..ae8fd0881b418 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -98,13 +98,11 @@ def _check_function_param_validation( "sklearn.cluster.compute_optics_graph", "sklearn.cluster.estimate_bandwidth", "sklearn.cluster.kmeans_plusplus", - "sklearn.cluster.spectral" "sklearn.covariance.empirical_covariance", "sklearn.covariance.shrunk_covariance", "sklearn.datasets.fetch_california_housing", "sklearn.datasets.make_sparse_coded_signal", "sklearn.decomposition.sparse_encode", - "sklearn.decomposition.fastica", "sklearn.feature_extraction.grid_to_graph", "sklearn.feature_extraction.img_to_graph", "sklearn.feature_extraction.image.extract_patches_2d", @@ -142,6 +140,7 @@ def test_function_param_validation(func_module): PARAM_VALIDATION_CLASS_WRAPPER_LIST = [ ("sklearn.cluster.affinity_propagation", "sklearn.cluster.AffinityPropagation"), + ("sklearn.cluster.spectral_clustering", "sklearn.cluster.SpectralClustering"), ("sklearn.covariance.ledoit_wolf", "sklearn.covariance.LedoitWolf"), ("sklearn.covariance.oas", "sklearn.covariance.OAS"), ("sklearn.decomposition.dict_learning", "sklearn.decomposition.DictionaryLearning"),