@@ -149,14 +149,11 @@ def __init__(self, ratio='auto', random_state=None, verbose=True,
149
149
else :
150
150
raise ValueError ('Unknown kind for SMOTE algorithm.' )
151
151
152
- # --- Verbose
153
- # Control whether or not status and progress information should be
154
- self .verbose = verbose
155
-
156
- # --- Nearest Neighbours for synthetic samples
157
- # The smote algorithm uses the k-th nearest neighbours of a minority
158
- # sample to generate new synthetic samples.
159
152
self .k = k
153
+ self .m = m
154
+ self .out_step = out_step
155
+ self .verbose = verbose
156
+ self .kwargs = kwargs
160
157
161
158
# --- NN object
162
159
# Import the NN object from scikit-learn library. Since in the smote
@@ -166,22 +163,18 @@ def __init__(self, ratio='auto', random_state=None, verbose=True,
166
163
# Regular smote does not look for samples in danger, instead it
167
164
# creates synthetic samples directly from the k-th nearest
168
165
# neighbours with not filtering
169
- self .nearest_neighbour = NearestNeighbors (n_neighbors = k + 1 ,
170
- n_jobs = self .n_jobs )
166
+ self .nearest_neighbour = NearestNeighbors (n_neighbors = self . k + 1 ,
167
+ n_jobs = self .n_jobs )
171
168
else :
172
169
# Borderline1, 2 and SVM variations of smote must first look for
173
170
# samples that could be considered noise and samples that live
174
171
# near the boundary between the classes. Therefore, before
175
172
# creating synthetic samples from the k-th nns, it first look
176
173
# for m nearest neighbors to decide whether or not a sample is
177
174
# noise or near the boundary.
178
- self .nearest_neighbour = NearestNeighbors (n_neighbors = m + 1 ,
179
- n_jobs = self .n_jobs )
175
+ self .nearest_neighbour = NearestNeighbors (n_neighbors = self . m + 1 ,
176
+ n_jobs = self .n_jobs )
180
177
181
- # --- Nearest Neighbours for noise and boundary (in danger)
182
- # Before creating synthetic samples we must first decide if
183
- # a given entry is noise or in danger. We use m nns in this step
184
- self .m = m
185
178
186
179
# --- SVM smote
187
180
# Unlike the borderline variations, the SVM variation uses the support
@@ -191,11 +184,8 @@ def __init__(self, ratio='auto', random_state=None, verbose=True,
191
184
# in danger (near the boundary). The level of extrapolation is
192
185
# controled by the out_step.
193
186
if kind == 'svm' :
194
- # Store extrapolation size
195
- self .out_step = out_step
196
-
197
187
# Store SVM object with any parameters
198
- self .svm = SVC (random_state = self .random_state , ** kwargs )
188
+ self .svm = SVC (random_state = self .random_state , ** self . kwargs )
199
189
200
190
def fit (self , X , y ):
201
191
"""Find the classes statistics before to perform sampling.
0 commit comments