File tree Expand file tree Collapse file tree 4 files changed +31
-3
lines changed
under_sampling/_prototype_selection Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 19
19
from sklearn .utils import check_array
20
20
from sklearn .utils .sparsefuncs_fast import csr_mean_variance_axis0
21
21
from sklearn .utils .sparsefuncs_fast import csc_mean_variance_axis0
22
- from sklearn .utils .fixes import _mode
23
22
24
23
from ..base import BaseOverSampler
25
24
from ...metrics .pairwise import ValueDifferenceMetric
29
28
from ...utils ._docstring import _n_jobs_docstring
30
29
from ...utils ._docstring import _random_state_docstring
31
30
from ...utils ._validation import _deprecate_positional_args
31
+ from ...utils .fixes import _mode
32
32
33
33
34
34
class BaseSMOTE (BaseOverSampler ):
Original file line number Diff line number Diff line change 11
11
import numpy as np
12
12
13
13
from sklearn .utils import _safe_indexing
14
- from sklearn .utils .fixes import _mode
15
14
16
15
from ..base import BaseCleaningSampler
17
16
from ...utils import check_neighbors_object
18
17
from ...utils import Substitution
19
18
from ...utils ._docstring import _n_jobs_docstring
20
19
from ...utils ._validation import _deprecate_positional_args
20
+ from ...utils .fixes import _mode
21
+
21
22
22
23
SEL_KIND = ("all" , "mode" )
23
24
Original file line number Diff line number Diff line change 9
9
import numpy as np
10
10
11
11
from sklearn .utils import _safe_indexing
12
- from sklearn .utils .fixes import _mode
13
12
14
13
from ..base import BaseCleaningSampler
15
14
from ._edited_nearest_neighbours import EditedNearestNeighbours
16
15
from ...utils import check_neighbors_object
17
16
from ...utils import Substitution
18
17
from ...utils ._docstring import _n_jobs_docstring
19
18
from ...utils ._validation import _deprecate_positional_args
19
+ from ...utils .fixes import _mode
20
+
20
21
21
22
SEL_KIND = ("all" , "mode" )
22
23
Original file line number Diff line number Diff line change
1
+ """Compatibility fixes for older version of python, numpy and scipy
2
+ If you add content to this file, please give the version of the package
3
+ at which the fix is no longer needed.
4
+
5
+ Backdated from scikit-learn.
6
+ """
7
+ # Authors: Emmanuelle Gouillart <emmanuelle.gouillart@normalesup.org>
8
+ # Gael Varoquaux <gael.varoquaux@normalesup.org>
9
+ # Fabian Pedregosa <fpedregosa@acm.org>
10
+ # Lars Buitinck
11
+ #
12
+ # License: BSD 3 clause
13
+
14
+ from sklearn .externals ._packaging .version import parse as parse_version
15
+ import scipy
16
+ import scipy .stats
17
+
18
+
19
+ sp_version = parse_version (scipy .__version__ )
20
+
21
+
22
+ # TODO: Remove when SciPy 1.9 is the minimum supported version
23
+ def _mode (a , axis = 0 ):
24
+ if sp_version >= parse_version ("1.9.0" ):
25
+ return scipy .stats .mode (a , axis = axis , keepdims = True )
26
+ return scipy .stats .mode (a , axis = axis )
You can’t perform that action at this time.
0 commit comments