1
- """Classes to perform under-sampling based on the edited nearest neighbour
1
+ """Classes to perform under-sampling based on the edited nearest neighbor
2
2
method."""
3
3
4
4
# Authors: Guillaume Lemaitre <[email protected] >
27
27
n_jobs = _n_jobs_docstring ,
28
28
)
29
29
class EditedNearestNeighbours (BaseCleaningSampler ):
30
- """Undersample based on the edited nearest neighbour method.
30
+ """Undersample based on the edited nearest neighbor method.
31
31
32
32
This method will clean the data set by removing samples close to the
33
33
decision boundary.
@@ -39,17 +39,17 @@ class EditedNearestNeighbours(BaseCleaningSampler):
39
39
{sampling_strategy}
40
40
41
41
n_neighbors : int or object, default=3
42
- If ``int``, size of the neighbourhood to consider to compute the
43
- nearest neighbours . If object, an estimator that inherits from
42
+ If ``int``, size of the neighborhood to consider to compute the
43
+ nearest neighbors . If object, an estimator that inherits from
44
44
:class:`~sklearn.neighbors.base.KNeighborsMixin` that will be used to
45
- find the nearest-neighbours .
45
+ find the nearest-neighbors .
46
46
47
47
kind_sel : {{'all', 'mode'}}, default='all'
48
48
Strategy to use in order to exclude samples.
49
49
50
- - If ``'all'``, all neighbours will have to agree with a sample in order
50
+ - If ``'all'``, all neighbors will have to agree with a sample in order
51
51
not to be excluded.
52
- - If ``'mode'``, the majority of the neighbours will have to agree with
52
+ - If ``'mode'``, the majority of the neighbors will have to agree with
53
53
a sample in order not to be excluded.
54
54
55
55
The strategy `"all"` will be less conservative than `'mode'`. Thus,
@@ -70,7 +70,7 @@ class EditedNearestNeighbours(BaseCleaningSampler):
70
70
71
71
RepeatedEditedNearestNeighbours : Undersample by repeating ENN algorithm.
72
72
73
- AllKNN : Undersample using ENN and various number of neighbours .
73
+ AllKNN : Undersample using ENN and various number of neighbors .
74
74
75
75
Notes
76
76
-----
@@ -172,7 +172,7 @@ def _more_tags(self):
172
172
n_jobs = _n_jobs_docstring ,
173
173
)
174
174
class RepeatedEditedNearestNeighbours (BaseCleaningSampler ):
175
- """Undersample based on the repeated edited nearest neighbour method.
175
+ """Undersample based on the repeated edited nearest neighbor method.
176
176
177
177
This method will repeat the ENN algorithm several times. The repetitions
178
178
will stop when i) the maximum number of iterations is reached, or ii) no
@@ -187,20 +187,20 @@ class RepeatedEditedNearestNeighbours(BaseCleaningSampler):
187
187
{sampling_strategy}
188
188
189
189
n_neighbors : int or object, default=3
190
- If ``int``, size of the neighbourhood to consider to compute the
191
- nearest neighbours . If object, an estimator that inherits from
190
+ If ``int``, size of the neighborhood to consider to compute the
191
+ nearest neighbors . If object, an estimator that inherits from
192
192
:class:`~sklearn.neighbors.base.KNeighborsMixin` that will be used to
193
- find the nearest-neighbours .
193
+ find the nearest-neighbors .
194
194
195
195
max_iter : int, default=100
196
- Maximum number of repetitions of the edited nearest neighbours algorithm.
196
+ Maximum number of repetitions of the edited nearest neighbors algorithm.
197
197
198
198
kind_sel : {{'all', 'mode'}}, default='all'
199
199
Strategy to use in order to exclude samples.
200
200
201
- - If ``'all'``, all neighbours will have to agree with a sample in order
201
+ - If ``'all'``, all neighbors will have to agree with a sample in order
202
202
not to be excluded.
203
- - If ``'mode'``, the majority of the neighbours will have to agree with
203
+ - If ``'mode'``, the majority of the neighbors will have to agree with
204
204
a sample in order not to be excluded.
205
205
206
206
The strategy `"all"` will be less conservative than `'mode'`. Thus,
@@ -226,7 +226,7 @@ class RepeatedEditedNearestNeighbours(BaseCleaningSampler):
226
226
227
227
EditedNearestNeighbours : Undersample by editing samples.
228
228
229
- AllKNN : Undersample using ENN and various number of neighbours .
229
+ AllKNN : Undersample using ENN and various number of neighbors .
230
230
231
231
Notes
232
232
-----
@@ -364,8 +364,8 @@ class AllKNN(BaseCleaningSampler):
364
364
"""Undersample based on the AllKNN method.
365
365
366
366
This method will apply ENN several times, starting by looking at the
367
- 1 closest neighbour , and increasing the number of nearest neighbours
368
- by 1 at each round, up to the number of neighbours specified in
367
+ 1 closest neighbor , and increasing the number of nearest neighbors
368
+ by 1 at each round, up to the number of neighbors specified in
369
369
`n_neighbors`.
370
370
371
371
The repetitions will stop when i) one of the majority classes
@@ -379,23 +379,24 @@ class AllKNN(BaseCleaningSampler):
379
379
{sampling_strategy}
380
380
381
381
n_neighbors : int or estimator object, default=3
382
- If ``int``, the maximum size of the neighbourhood to evaluate.
383
- The method will start by looking at the 1 closest neighbour , and
384
- then repeat the edited nearest neighbours increasing
385
- the neighbourhood by 1, until examining a neighbourhood of
382
+ If ``int``, the maximum size of the the neighborhood to evaluate.
383
+ The method will start by looking at the 1 closest neighbor , and
384
+ then repeat the edited nearest neighbors increasing
385
+ the neighborhood by 1, until examining a neighborhood of
386
386
`n_neighbors` in the final iteration.
387
+
387
388
If object, an estimator that inherits from
388
389
:class:`~sklearn.neighbors.base.KNeighborsMixin` that will be used to
389
- find the nearest-neighbours in the final round. In this case,
390
- AllKNN will repeat edited nearest neighbours starting from a 2-KNN
390
+ find the nearest-neighbors in the final round. In this case,
391
+ AllKNN will repeat edited nearest neighbors starting from a 2-KNN
391
392
up to the specified KNN in the object.
392
393
393
394
kind_sel : {{'all', 'mode'}}, default='all'
394
395
Strategy to use in order to exclude samples.
395
396
396
- - If ``'all'``, all neighbours will have to agree with a sample in order
397
+ - If ``'all'``, all neighbors will have to agree with a sample in order
397
398
not to be excluded.
398
- - If ``'mode'``, the majority of the neighbours will have to agree with
399
+ - If ``'mode'``, the majority of the neighbors will have to agree with
399
400
a sample in order not to be excluded.
400
401
401
402
The strategy `"all"` will be less conservative than `'mode'`. Thus,
@@ -434,7 +435,7 @@ class without early stopping.
434
435
References
435
436
----------
436
437
.. [1] I. Tomek, "An Experiment with the Edited Nearest-Neighbor
437
- Rule," IEEE Transactions on Systems, Man, and Cybernetics, vol. 6(6),
438
+ Rule", IEEE Transactions on Systems, Man, and Cybernetics, vol. 6(6),
438
439
pp. 448-452, June 1976.
439
440
440
441
Examples
0 commit comments