Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sklearn/feature_selection/_univariate_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions sklearn/tests/test_public_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down