Skip to content

Fix docstring about sampling strategy for under and oversampling #525

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

Merged
merged 4 commits into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/whats_new/v0.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Version 0.5 (under development)
Changelog
---------

Documentation
.............

- Correct the definition of the ratio when using a ``float`` in sampling
strategy for the over-sampling and under-sampling.
:issue:`525` by :user:`Ariel Rossanigo <arielrossanigo>`.

Maintenance
...........

Expand Down
2 changes: 1 addition & 1 deletion examples/plot_sampling_strategy_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def my_autopct(pct):

###############################################################################
# For **over-sampling methods**, it correspond to the ratio
# :math:`\\alpha_{os}` defined by :math:`N_{rm} = \\alpha_{os} \\times N_{m}`
# :math:`\\alpha_{os}` defined by :math:`N_{rm} = \\alpha_{os} \\times N_{M}`
# where :math:`N_{rm}` and :math:`N_{M}` are the number of samples in the
# minority class after resampling and the number of samples in the majority
# class, respectively.
Expand Down
11 changes: 5 additions & 6 deletions imblearn/over_sampling/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ class BaseOverSampler(BaseSampler):
Sampling information to resample the data set.

- When ``float``, it corresponds to the desired ratio of the number of
samples in the majority class over the number of samples in the
minority class after resampling. Therefore, the ratio is expressed as
:math:`\\alpha_{os} = N_{M} / N_{rm}` where :math:`N_{rm}` and
:math:`N_{M}` are the number of samples in the minority class after
resampling and the number of samples in the majority class,
respectively.
samples in the minority class over the number of samples in the
majority class after resampling. Therefore, the ratio is expressed as
:math:`\\alpha_{os} = N_{rm} / N_{M}` where :math:`N_{rm}` is the
number of samples in the minority class after resampling and
:math:`N_{M}` is the number of samples in the majority class.

.. warning::
``float`` is only available for **binary** classification. An
Expand Down
12 changes: 6 additions & 6 deletions imblearn/under_sampling/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class BaseUnderSampler(BaseSampler):
Sampling information to sample the data set.

- When ``float``, it corresponds to the desired ratio of the number of
samples in the majority class over the number of samples in the
minority class after resampling. Therefore, the ratio is expressed as
:math:`\\alpha_{us} = N_{rM} / N_{m}` where :math:`N_{rM}` and
:math:`N_{m}` are the number of samples in the majority class after
resampling and the number of samples in the minority class,
respectively.
samples in the minority class over the number of samples in the
majority class after resampling. Therefore, the ratio is expressed as
:math:`\\alpha_{us} = N_{m} / N_{rM}` where :math:`N_{m}` is the
number of samples in the minority class and
:math:`N_{rM}` is the number of samples in the majority class
after resampling.

.. warning::
``float`` is only available for **binary** classification. An
Expand Down