Reputation: 1023
I want to use RandomOverSampler function from imbalanced-learn module to perform oversampling the data with more than two classes. The following is my code with 3 classes:
import numpy as np
from imblearn.over_sampling import RandomOverSampler
data = np.random.randn(30,5)
label = np.random.randint(3, size=30)
ros = RandomOverSampler(random_state=3)
data_res, label_res = ada.fit_sample(data, label)
After running, it returns this warning:
UserWarning: The target type should be binary. warnings.warn('The target type should be binary.')
But the documentation says:
Notes
Supports mutli-class resampling.
Am I missing something to use it for multi class case? If this is only for binary class, is there any other library or module which supports multi class oversampling?
Upvotes: 3
Views: 6665
Reputation: 1
RandomOverSampler() works very well for me on a multi-class problem with 9 labels I see on your code that you are using ada oversampler instead of ros that you defined.
Upvotes: 0
Reputation: 21
I faced the same situation yesterday,
and I used conda to install the library,
I found the file -> base.py
it had something different with the newest version on github.
so I git clone the newest version by github
https://github.com/scikit-learn-contrib/imbalanced-learn
and then,
everythings is ok!
u can use multi-class well
Upvotes: 2