7
7
from __future__ import division
8
8
9
9
import logging
10
- import warnings
11
10
12
11
from sklearn .utils import check_X_y
13
12
@@ -54,82 +53,6 @@ class SMOTEENN(SamplerMixin):
54
53
a :class:`imblearn.over_sampling.SMOTE` object with default parameters
55
54
will be given.
56
55
57
- enn : object, optional (default=EditedNearestNeighbours())
58
- The :class:`imblearn.under_sampling.EditedNearestNeighbours` object to
59
- use. If not given, an
60
- :class:`imblearn.under_sampling.EditedNearestNeighbours` object with
61
- default parameters will be given.
62
-
63
- k : int, optional (default=None)
64
- Number of nearest neighbours to used to construct synthetic
65
- samples.
66
-
67
- .. deprecated:: 0.2
68
- `k` is deprecated from 0.2 and will be replaced in 0.4
69
- Give directly a :class:`imblearn.over_sampling.SMOTE` object.
70
-
71
- m : int, optional (default=None)
72
- Number of nearest neighbours to use to determine if a minority
73
- sample is in danger.
74
-
75
- .. deprecated:: 0.2
76
- `m` is deprecated from 0.2 and will be replaced in 0.4
77
- Give directly a :class:`imblearn.over_sampling.SMOTE` object.
78
-
79
- out_step : float, optional (default=None)
80
- Step size when extrapolating.
81
-
82
- .. deprecated:: 0.2
83
- ``out_step`` is deprecated from 0.2 and will be replaced in 0.4
84
- Give directly a :class:`imblearn.over_sampling.SMOTE` object.
85
-
86
- kind_smote : str, optional (default=None)
87
- The type of SMOTE algorithm to use one of the following
88
- options: ``'regular'``, ``'borderline1'``, ``'borderline2'``,
89
- ``'svm'``.
90
-
91
- .. deprecated:: 0.2
92
- `kind_smote` is deprecated from 0.2 and will be replaced in 0.4
93
- Give directly a :class:`imblearn.over_sampling.SMOTE` object.
94
-
95
- size_ngh : int, optional (default=None)
96
- Size of the neighbourhood to consider to compute the average
97
- distance to the minority point samples.
98
-
99
- .. deprecated:: 0.2
100
- size_ngh is deprecated from 0.2 and will be replaced in 0.4
101
- Use ``n_neighbors`` instead.
102
-
103
- n_neighbors : int, optional (default=None)
104
- Size of the neighbourhood to consider to compute the average
105
- distance to the minority point samples.
106
-
107
- .. deprecated:: 0.2
108
- `n_neighbors` is deprecated from 0.2 and will be replaced in 0.4
109
- Give directly a
110
- :class:`imblearn.under_sampling.EditedNearestNeighbours` object.
111
-
112
- kind_sel : str, optional (default=None)
113
- Strategy to use in order to exclude samples.
114
-
115
- - If ``'all'``, all neighbours will have to agree with the samples of
116
- interest to not be excluded.
117
- - If ``'mode'``, the majority vote of the neighbours will be used in
118
- order to exclude a sample.
119
-
120
- .. deprecated:: 0.2
121
- ``kind_sel`` is deprecated from 0.2 and will be replaced in 0.4 Give
122
- directly a :class:`imblearn.under_sampling.EditedNearestNeighbours`
123
- object.
124
-
125
- n_jobs : int, optional (default=None)
126
- The number of threads to open if possible.
127
-
128
- .. deprecated:: 0.2
129
- `n_jobs` is deprecated from 0.2 and will be replaced in 0.4 Give
130
- directly a :class:`imblearn.over_sampling.SMOTE` and
131
- :class:`imblearn.under_sampling.EditedNearestNeighbours` object.
132
-
133
56
Notes
134
57
-----
135
58
The method is presented in [1]_.
@@ -173,65 +96,17 @@ def __init__(self,
173
96
ratio = 'auto' ,
174
97
random_state = None ,
175
98
smote = None ,
176
- enn = None ,
177
- k = None ,
178
- m = None ,
179
- out_step = None ,
180
- kind_smote = None ,
181
- size_ngh = None ,
182
- n_neighbors = None ,
183
- kind_enn = None ,
184
- n_jobs = None ):
99
+ enn = None ):
185
100
super (SMOTEENN , self ).__init__ ()
186
101
self .ratio = ratio
187
102
self .random_state = random_state
188
103
self .smote = smote
189
104
self .enn = enn
190
- self .k = k
191
- self .m = m
192
- self .out_step = out_step
193
- self .kind_smote = kind_smote
194
- self .size_ngh = size_ngh
195
- self .n_neighbors = n_neighbors
196
- self .kind_enn = kind_enn
197
- self .n_jobs = n_jobs
198
105
self .logger = logging .getLogger (__name__ )
199
106
200
107
def _validate_estimator (self ):
201
108
"Private function to validate SMOTE and ENN objects"
202
-
203
- # Check any parameters for SMOTE was provided
204
- # Anounce deprecation
205
- if (self .k is not None or self .m is not None or
206
- self .out_step is not None or self .kind_smote is not None or
207
- self .n_jobs is not None ):
208
- # We need to list each parameter and decide if we affect a default
209
- # value or not
210
- if self .k is None :
211
- self .k = 5
212
- if self .m is None :
213
- self .m = 10
214
- if self .out_step is None :
215
- self .out_step = 0.5
216
- if self .kind_smote is None :
217
- self .kind_smote = 'regular'
218
- if self .n_jobs is None :
219
- smote_jobs = 1
220
- else :
221
- smote_jobs = self .n_jobs
222
- warnings .warn ('Parameters initialization will be replaced in'
223
- ' version 0.4. Use a SMOTE object instead.' ,
224
- DeprecationWarning )
225
- self .smote_ = SMOTE (
226
- ratio = self .ratio ,
227
- random_state = self .random_state ,
228
- k = self .k ,
229
- m = self .m ,
230
- out_step = self .out_step ,
231
- kind = self .kind_smote ,
232
- n_jobs = smote_jobs )
233
- # If an object was given, affect
234
- elif self .smote is not None :
109
+ if self .smote is not None :
235
110
if isinstance (self .smote , SMOTE ):
236
111
self .smote_ = self .smote
237
112
else :
@@ -242,30 +117,7 @@ def _validate_estimator(self):
242
117
self .smote_ = SMOTE (
243
118
ratio = self .ratio , random_state = self .random_state )
244
119
245
- # Check any parameters for ENN was provided
246
- # Anounce deprecation
247
- if (self .size_ngh is not None or self .n_neighbors is not None or
248
- self .kind_enn is not None or self .n_jobs is not None ):
249
- warnings .warn ('Parameters initialization will be replaced in'
250
- ' version 0.4. Use a ENN object instead.' ,
251
- DeprecationWarning )
252
- # We need to list each parameter and decide if we affect a default
253
- # value or not
254
- if self .n_neighbors is None :
255
- self .n_neighbors = 3
256
- if self .kind_enn is None :
257
- self .kind_enn = 'all'
258
- if self .n_jobs is None :
259
- self .n_jobs = 1
260
- self .enn_ = EditedNearestNeighbours (
261
- ratio = 'all' ,
262
- random_state = self .random_state ,
263
- size_ngh = self .size_ngh ,
264
- n_neighbors = self .n_neighbors ,
265
- kind_sel = self .kind_enn ,
266
- n_jobs = self .n_jobs )
267
- # If an object was given, affect
268
- elif self .enn is not None :
120
+ if self .enn is not None :
269
121
if isinstance (self .enn , EditedNearestNeighbours ):
270
122
self .enn_ = self .enn
271
123
else :
0 commit comments