@@ -94,29 +94,31 @@ Imbalanced generator
94
94
====================
95
95
96
96
:func: `make_imbalance ` turns an original dataset into an imbalanced
97
- dataset. This behaviour is driven by the parameter ``ratio `` which behave
98
- similarly to other resampling algorithm. ``ratio `` can be given as a dictionary
99
- where the key corresponds to the class and the value is the the number of
100
- samples in the class::
97
+ dataset. This behaviour is driven by the parameter ``sampling_strategy `` which
98
+ behave similarly to other resampling algorithm. ``sampling_strategy `` can be
99
+ given as a dictionary where the key corresponds to the class and the value is
100
+ the number of samples in the class::
101
101
102
102
>>> from sklearn.datasets import load_iris
103
103
>>> from imblearn.datasets import make_imbalance
104
104
>>> iris = load_iris()
105
- >>> ratio = {0: 20, 1: 30, 2: 40}
106
- >>> X_imb, y_imb = make_imbalance(iris.data, iris.target, ratio=ratio)
105
+ >>> sampling_strategy = {0: 20, 1: 30, 2: 40}
106
+ >>> X_imb, y_imb = make_imbalance(iris.data, iris.target,
107
+ ... sampling_strategy=sampling_strategy)
107
108
>>> sorted(Counter(y_imb).items())
108
109
[(0, 20), (1, 30), (2, 40)]
109
110
110
111
Note that all samples of a class are passed-through if the class is not mentioned
111
112
in the dictionary::
112
113
113
- >>> ratio = {0: 10}
114
- >>> X_imb, y_imb = make_imbalance(iris.data, iris.target, ratio=ratio)
114
+ >>> sampling_strategy = {0: 10}
115
+ >>> X_imb, y_imb = make_imbalance(iris.data, iris.target,
116
+ ... sampling_strategy=sampling_strategy)
115
117
>>> sorted(Counter(y_imb).items())
116
118
[(0, 10), (1, 50), (2, 50)]
117
119
118
120
Instead of a dictionary, a function can be defined and directly pass to
119
- ``ratio ``::
121
+ ``sampling_strategy ``::
120
122
121
123
>>> def ratio_multiplier(y):
122
124
... multiplier = {0: 0.5, 1: 0.7, 2: 0.95}
@@ -125,9 +127,9 @@ Instead of a dictionary, a function can be defined and directly pass to
125
127
... target_stats[key] = int(value * multiplier[key])
126
128
... return target_stats
127
129
>>> X_imb, y_imb = make_imbalance(iris.data, iris.target,
128
- ... ratio =ratio_multiplier)
130
+ ... sampling_strategy =ratio_multiplier)
129
131
>>> sorted(Counter(y_imb).items())
130
132
[(0, 25), (1, 35), (2, 47)]
131
133
132
134
See :ref: `sphx_glr_auto_examples_datasets_plot_make_imbalance.py ` and
133
- :ref: `sphx_glr_auto_examples_plot_ratio_usage .py `.
135
+ :ref: `sphx_glr_auto_examples_plot_sampling_strategy_usage .py `.
0 commit comments