diff --git a/sklearn/feature_selection/_univariate_selection.py b/sklearn/feature_selection/_univariate_selection.py index a2a53b6c116dd..5521a62649c81 100644 --- a/sklearn/feature_selection/_univariate_selection.py +++ b/sklearn/feature_selection/_univariate_selection.py @@ -17,7 +17,7 @@ from ..utils import as_float_array, check_array, check_X_y, safe_sqr, safe_mask from ..utils.extmath import safe_sparse_dot, row_norms from ..utils.validation import check_is_fitted -from ..utils._param_validation import Interval, StrOptions +from ..utils._param_validation import Interval, StrOptions, validate_params from ._base import SelectorMixin @@ -167,6 +167,12 @@ def _chisquare(f_obs, f_exp): return chisq, special.chdtrc(k - 1, chisq) +@validate_params( + { + "X": ["array-like", "sparse matrix"], + "y": ["array-like"], + } +) def chi2(X, y): """Compute chi-squared stats between each non-negative feature and class. diff --git a/sklearn/tests/test_public_functions.py b/sklearn/tests/test_public_functions.py index dae1fdb2e6164..4fe337e9a95ea 100644 --- a/sklearn/tests/test_public_functions.py +++ b/sklearn/tests/test_public_functions.py @@ -112,6 +112,7 @@ def _check_function_param_validation( "sklearn.feature_extraction.img_to_graph", "sklearn.feature_extraction.image.extract_patches_2d", "sklearn.feature_extraction.image.reconstruct_from_patches_2d", + "sklearn.feature_selection.chi2", "sklearn.metrics.accuracy_score", "sklearn.metrics.auc", "sklearn.metrics.average_precision_score",