Skip to content

[MRG] updates docstrings and user guide for ENN, RENN and AllKNN #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed

Conversation

solegalli
Copy link
Contributor

@solegalli solegalli commented Aug 4, 2021

Reference Issue

#851

What does this implement/fix? Explain your changes.

Expands docstrings and user guide for ENN, RENN and AllKNN.

Any other comments?

I had some trouble understanding the implementation of the algorithms. In short, I thought that to explore the 3 closest neighbours a 3-KNN should be trained. As it turns out, it needs to be a 4 KNN. I also had trouble understanding when the
RENN and AllKNN stop and why. And finally, the parameter n_neighbours in ENN and RENN does not elicit the same behaviour as in AllKNN, so I think tit helps to clarify.

@@ -1,4 +1,4 @@
"""Class to perform under-sampling based on the edited nearest neighbour
"""Classes to perform under-sampling based on the edited nearest neighbour
Copy link
Contributor Author

@solegalli solegalli Aug 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs and API use both the form of the word neighbo(u)r with and without u. Sklearn uses neighbor without u in its classes names, imbalanced learn uses neighbour with u in the classes names and without u in the parameters and attributes. The docstrings had a bit of both.

I unified the docstrings to Neighbors without u.

At some point it might be good considering unifying also the class name .

will stop when i) the maximum number of iterations is reached, or ii) no
more observations are being removed, or iii) one of the majority classes
becomes a minority class or iv) one of the majority classes disappears
from the target after undersampling.

Copy link
Contributor Author

@solegalli solegalli Aug 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a way to understanding how the algo stops, unless we read the source code. So I added this bit.

# (that is, if no further observations are removed)
# 2. If the number of samples in any of the other (majority) classes becomes
# smaller than the number of samples in the minority class
# 3. If one of the classes disappears
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had trouble understanding the comments and the logic so I rephrased a bit

The repetitions will stop when i) the maximum number of iterations
is reached, or ii) one of the majority classes becomes a minority
class or iii) one of the majority classes disappears from the target
after undersampling.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helps user understand when repetitions stop, without looking at source code

@solegalli solegalli changed the title fix neighbours in enn, renn and allkk, changes allknn logic, fixes typos in docs and comments [MRG} fix neighbours in enn, renn and allkk, changes allknn logic, fixes typos in docs and comments Aug 5, 2021
@solegalli solegalli changed the title [MRG} fix neighbours in enn, renn and allkk, changes allknn logic, fixes typos in docs and comments [MRG] fix neighbours in enn, renn and allkk, changes allknn logic, fixes typos in docs and comments Aug 5, 2021
@solegalli solegalli changed the title [MRG] fix neighbours in enn, renn and allkk, changes allknn logic, fixes typos in docs and comments [MRG] fix neighbours in enn, renn and allknn, changes allknn logic, fixes typos in docs and comments Aug 5, 2021
@solegalli solegalli changed the title [MRG] fix neighbours in enn, renn and allknn, changes allknn logic, fixes typos in docs and comments [REVIEW] fix neighbours in enn, renn and allknn, changes allknn logic, fixes typos in docs and comments Aug 5, 2021
@solegalli solegalli changed the title [REVIEW] fix neighbours in enn, renn and allknn, changes allknn logic, fixes typos in docs and comments [WIP] fix neighbours in enn, renn and allknn, changes allknn logic, fixes typos in docs and comments Aug 5, 2021
@solegalli solegalli changed the title [WIP] fix neighbours in enn, renn and allknn, changes allknn logic, fixes typos in docs and comments [WIP] changes allknn logic, fixes typos in docs and comments Aug 5, 2021
@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #850 (dae3e2e) into master (edf6eae) will not change coverage.
The diff coverage is n/a.

❗ Current head dae3e2e differs from pull request most recent head 1be039e. Consider uploading reports for the commit 1be039e to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master     #850   +/-   ##
=======================================
  Coverage   98.69%   98.69%           
=======================================
  Files          93       93           
  Lines        6063     6063           
  Branches      508      508           
=======================================
  Hits         5984     5984           
  Misses         78       78           
  Partials        1        1           
Impacted Files Coverage Δ
..._prototype_selection/_edited_nearest_neighbours.py 100.00% <ø> (ø)
imblearn/utils/_validation.py 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update edf6eae...1be039e. Read the comment docs.

@solegalli solegalli changed the title [WIP] changes allknn logic, fixes typos in docs and comments [WIP] fixes typos in docs and comments, updates docstrings Aug 5, 2021
@solegalli solegalli changed the title [WIP] fixes typos in docs and comments, updates docstrings [MRG] fixes typos in docs and comments, updates docstrings Aug 5, 2021
@solegalli solegalli changed the title [MRG] fixes typos in docs and comments, updates docstrings [MRG] updates docstrings and user guide for ENN, RENN and AllKNN Aug 5, 2021
@solegalli
Copy link
Contributor Author

@glemaitre I think this is ready for review

@solegalli
Copy link
Contributor Author

@glemaitre would you like me to reopen and update this PR?

@glemaitre
Copy link
Member

I could find some time to review. However, it would be easier for me to have 1 PR by samplers. Could you split the PR @solegalli

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants