Skip to content

Commit

Permalink
[MRG] FIX Fixes failure in interpolation of ADASYN (scikit-learn-cont…
Browse files Browse the repository at this point in the history
…rib#235)

* Fixed ADASYN

* Added bug fix to list

* Updated tests
  • Loading branch information
Eichhof authored and glemaitre committed Feb 21, 2017
1 parent 5413a29 commit 722e223
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Bug fixes
- Fixed a bug in :class:`pipeline.Pipeline`, solve the issue to put to sampler in the same `Pipeline`. By `Christos Aridas`_ .
- Fixed a bug in :class:`under_sampling.CondensedNeareastNeigbour`, correction of the shape of `sel_x` when only one sample is selected. By `Aliaksei Halachkin`_.
- Fixed a bug in :class:`under_sampling.NeighbourhoodCleaningRule`, selecting neighbours instead of minority class misclassified samples. By `Aleksandr Loskutov`_.
- Fixed a bug in :class:`over_sampling.ADASYN`, correction of the creation of a new sample so that the new sample lies between the minority sample and the nearest neighbour. By `Rafael Wampfler`_.

New features
~~~~~~~~~~~~
Expand Down Expand Up @@ -119,3 +120,4 @@ New methods
.. _Francois Magimel: https://github.com/Linkid
.. _Aliaksei Halachkin: https://github.com/honeyext
.. _Aleksandr Loskutov: https://github.com/loskutyan
.. _Rafael Wampfler: https://github.com/Eichhof
2 changes: 1 addition & 1 deletion imblearn/over_sampling/adasyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _sample(self, X, y):
# Create a new sample
for nn_z in nn_zs:
step = random_state.uniform()
x_gen = x_i + step * (x_i - X[x_i_nn[nn_z], :])
x_gen = x_i + step * (X[x_i_nn[nn_z], :] - x_i)
X_resampled = np.vstack((X_resampled, x_gen))
y_resampled = np.hstack((y_resampled, self.min_c_))

Expand Down
8 changes: 4 additions & 4 deletions imblearn/over_sampling/tests/test_adasyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def test_ada_fit_sample():
[-0.18410027, -0.45194484], [0.9281014, 0.53085498],
[-0.14374509, 0.27370049], [-0.41635887, -0.38299653],
[0.08711622, 0.93259929], [1.70580611, -0.11219234],
[0.29427267, 0.21740707], [0.68118697, -0.25220353],
[1.37180201, 0.37279378], [-0.59243851, -0.80715327]])
[-0.06182085, -0.28084828], [0.38614986, -0.35405599],
[0.39635544, 0.33629036], [-0.24027923, 0.04116021]])
y_gt = np.array([
0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0
])
Expand Down Expand Up @@ -204,8 +204,8 @@ def test_ada_fit_sample_nn_obj():
[-0.18410027, -0.45194484], [0.9281014, 0.53085498],
[-0.14374509, 0.27370049], [-0.41635887, -0.38299653],
[0.08711622, 0.93259929], [1.70580611, -0.11219234],
[0.29427267, 0.21740707], [0.68118697, -0.25220353],
[1.37180201, 0.37279378], [-0.59243851, -0.80715327]])
[-0.06182085, -0.28084828], [0.38614986, -0.35405599],
[0.39635544, 0.33629036], [-0.24027923, 0.04116021]])
y_gt = np.array([
0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0
])
Expand Down

0 comments on commit 722e223

Please sign in to comment.