Skip to content

Commit 6769490

Browse files
thomasjpfanqinhanmin2014
authored andcommitted
MNT Make modules private in feature_selection (scikit-learn#15376)
1 parent 4d749ea commit 6769490

13 files changed

+47
-24
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,10 @@ sklearn/semi_supervised/label_propagation.py
223223

224224
sklearn/preprocessing/data.py
225225
sklearn/preprocessing/label.py
226+
227+
sklearn/feature_selection/base.py
228+
sklearn/feature_selection/from_model.py
229+
sklearn/feature_selection/mutual_info.py
230+
sklearn/feature_selection/rfe.py
231+
sklearn/feature_selection/univariate_selection.py
232+
sklearn/feature_selection/variance_threshold.py

sklearn/_build_utils/deprecated_modules.py

+15
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,21 @@
248248
('_label', 'sklearn.preprocessing.label', 'sklearn.preprocessing',
249249
'LabelEncoder'),
250250

251+
('_base', 'sklearn.feature_selection.base', 'sklearn.feature_selection',
252+
'SelectorMixin'),
253+
('_from_model', 'sklearn.feature_selection.from_model',
254+
'sklearn.feature_selection', 'SelectFromModel'),
255+
('_mutual_info', 'sklearn.feature_selection.mutual_info',
256+
'sklearn.feature_selection', 'mutual_info_regression'),
257+
('_rfe', 'sklearn.feature_selection.rfe',
258+
'sklearn.feature_selection.rfe', 'RFE'),
259+
('_univariate_selection',
260+
'sklearn.feature_selection.univariate_selection',
261+
'sklearn.feature_selection', 'chi2'),
262+
('_variance_threshold',
263+
'sklearn.feature_selection.variance_threshold',
264+
'sklearn.feature_selection', 'VarianceThreshold'),
265+
251266
('_testing', 'sklearn.utils.testing', 'sklearn.utils',
252267
'all_estimators'),
253268
]

sklearn/feature_selection/__init__.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
recursive feature elimination algorithm.
55
"""
66

7-
from .univariate_selection import chi2
8-
from .univariate_selection import f_classif
9-
from .univariate_selection import f_oneway
10-
from .univariate_selection import f_regression
11-
from .univariate_selection import SelectPercentile
12-
from .univariate_selection import SelectKBest
13-
from .univariate_selection import SelectFpr
14-
from .univariate_selection import SelectFdr
15-
from .univariate_selection import SelectFwe
16-
from .univariate_selection import GenericUnivariateSelect
7+
from ._univariate_selection import chi2
8+
from ._univariate_selection import f_classif
9+
from ._univariate_selection import f_oneway
10+
from ._univariate_selection import f_regression
11+
from ._univariate_selection import SelectPercentile
12+
from ._univariate_selection import SelectKBest
13+
from ._univariate_selection import SelectFpr
14+
from ._univariate_selection import SelectFdr
15+
from ._univariate_selection import SelectFwe
16+
from ._univariate_selection import GenericUnivariateSelect
1717

18-
from .variance_threshold import VarianceThreshold
18+
from ._variance_threshold import VarianceThreshold
1919

20-
from .rfe import RFE
21-
from .rfe import RFECV
20+
from ._rfe import RFE
21+
from ._rfe import RFECV
2222

23-
from .from_model import SelectFromModel
23+
from ._from_model import SelectFromModel
2424

25-
from .mutual_info_ import mutual_info_regression, mutual_info_classif
25+
from ._mutual_info import mutual_info_regression, mutual_info_classif
2626

2727

2828
__all__ = ['GenericUnivariateSelect',

sklearn/feature_selection/from_model.py renamed to sklearn/feature_selection/_from_model.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55
import numbers
66

7-
from .base import SelectorMixin
7+
from ._base import SelectorMixin
88
from ..base import BaseEstimator, clone, MetaEstimatorMixin
99

1010
from ..exceptions import NotFittedError

sklearn/feature_selection/rfe.py renamed to sklearn/feature_selection/_rfe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ..model_selection import check_cv
2121
from ..model_selection._validation import _score
2222
from ..metrics import check_scoring
23-
from .base import SelectorMixin
23+
from ._base import SelectorMixin
2424

2525

2626
def _rfe_single_fit(rfe, estimator, X, y, train, test, scorer):

sklearn/feature_selection/univariate_selection.py renamed to sklearn/feature_selection/_univariate_selection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
safe_mask)
1818
from ..utils.extmath import safe_sparse_dot, row_norms
1919
from ..utils.validation import check_is_fitted
20-
from .base import SelectorMixin
20+
from ._base import SelectorMixin
2121

2222

2323
def _clean_nans(scores):

sklearn/feature_selection/variance_threshold.py renamed to sklearn/feature_selection/_variance_threshold.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import numpy as np
55
from ..base import BaseEstimator
6-
from .base import SelectorMixin
6+
from ._base import SelectorMixin
77
from ..utils import check_array
88
from ..utils.sparsefuncs import mean_variance_axis, min_max_axis
99
from ..utils.validation import check_is_fitted

sklearn/feature_selection/tests/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from numpy.testing import assert_array_equal
66

77
from sklearn.base import BaseEstimator
8-
from sklearn.feature_selection.base import SelectorMixin
8+
from sklearn.feature_selection._base import SelectorMixin
99
from sklearn.utils import check_array
1010

1111

sklearn/feature_selection/tests/test_chi2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import scipy.stats
1212

1313
from sklearn.feature_selection import SelectKBest, chi2
14-
from sklearn.feature_selection.univariate_selection import _chisquare
14+
from sklearn.feature_selection._univariate_selection import _chisquare
1515
from sklearn.utils._testing import assert_array_almost_equal
1616
from sklearn.utils._testing import assert_array_equal
1717

sklearn/feature_selection/tests/test_mutual_info.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
from sklearn.utils import check_random_state
77
from sklearn.utils._testing import assert_array_equal, assert_almost_equal
8-
from sklearn.feature_selection.mutual_info_ import (
9-
mutual_info_regression, mutual_info_classif, _compute_mi)
8+
from sklearn.feature_selection._mutual_info import _compute_mi
9+
from sklearn.feature_selection import (mutual_info_regression,
10+
mutual_info_classif)
1011

1112

1213
def test_compute_mi_dd():

sklearn/feature_selection/tests/test_rfe.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from numpy.testing import assert_array_almost_equal, assert_array_equal
77
from scipy import sparse
88

9-
from sklearn.feature_selection.rfe import RFE, RFECV
9+
from sklearn.feature_selection import RFE, RFECV
1010
from sklearn.datasets import load_iris, make_friedman1
1111
from sklearn.metrics import zero_one_loss
1212
from sklearn.svm import SVC, SVR

0 commit comments

Comments
 (0)