From 771ea70abf8b3d0753bb515d56a6a3e87305abc6 Mon Sep 17 00:00:00 2001 From: jiawei-zhang-a Date: Mon, 3 Apr 2023 19:23:34 -0400 Subject: [PATCH 1/3] MAINT Parameters validation for sklearn.preprocessing.maxabs_scale --- sklearn/preprocessing/_data.py | 7 +++++++ sklearn/tests/test_public_functions.py | 1 + 2 files changed, 8 insertions(+) diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index 0c5b0123dff13..690472f2facea 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -1292,6 +1292,13 @@ def _more_tags(self): return {"allow_nan": True} +@validate_params( + { + "X": ["array-like", "sparse matrix"], + "axis": [Options(Integral, {0, 1})], + "copy": ["boolean"], + } +) def maxabs_scale(X, *, axis=0, copy=True): """Scale each feature to the [-1, 1] range without breaking the sparsity. diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index b2d6b0da4f379..b62fbf521cc74 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -220,6 +220,7 @@ def _check_function_param_validation( "sklearn.model_selection.train_test_split", "sklearn.preprocessing.add_dummy_feature", "sklearn.preprocessing.scale", + "sklearn.preprocessing.maxabs_scale", "sklearn.random_projection.johnson_lindenstrauss_min_dim", "sklearn.svm.l1_min_c", "sklearn.tree.export_text", From 0cffc7c441e7a9403b035386459bc7f08e416dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20du=20Boisberranger?= <34657725+jeremiedbb@users.noreply.github.com> Date: Tue, 4 Apr 2023 11:59:43 +0200 Subject: [PATCH 2/3] Update _data.py --- sklearn/preprocessing/_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/preprocessing/_data.py b/sklearn/preprocessing/_data.py index 690472f2facea..ea5fc2d44516d 100644 --- a/sklearn/preprocessing/_data.py +++ b/sklearn/preprocessing/_data.py @@ -1313,7 +1313,7 @@ def maxabs_scale(X, *, axis=0, copy=True): X : {array-like, sparse matrix} of shape (n_samples, n_features) The data. - axis : int, default=0 + axis : {0, 1}, default=0 Axis used to scale along. If 0, independently scale each feature, otherwise (if 1) scale each sample. From 281f5b9ab9ec4b025a77867d585265a9b8be61c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20du=20Boisberranger?= <34657725+jeremiedbb@users.noreply.github.com> Date: Tue, 4 Apr 2023 12:00:20 +0200 Subject: [PATCH 3/3] Update test_public_functions.py --- sklearn/tests/test_public_functions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index b62fbf521cc74..db3882a4914f3 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -219,8 +219,8 @@ def _check_function_param_validation( "sklearn.metrics.zero_one_loss", "sklearn.model_selection.train_test_split", "sklearn.preprocessing.add_dummy_feature", - "sklearn.preprocessing.scale", "sklearn.preprocessing.maxabs_scale", + "sklearn.preprocessing.scale", "sklearn.random_projection.johnson_lindenstrauss_min_dim", "sklearn.svm.l1_min_c", "sklearn.tree.export_text",