Reputation: 1589
I am trying to deal with imbalanced data set using imblearn's random under-sampler. I want to specify the number of labels to be under-sampled manually. Here is my code:
sm = RandomUnderSampler(ratio = {0:142498, 1: 495}, random_state=42)
X_train, y_train = sm.fit_sample(X_tr,encoded_Ytrain)
print(format(Counter(y_train)))
However, this throws the error:
File "first_approach.py", line 56, in < module > X_train, y_train = sm.fit_sample(X_tr,encoded_Ytrain) raise ValueError('Unknown parameter type for ratio.') ValueError: Unknown parameter type for ratio.
What should be the correct syntax for passing the same?
Upvotes: 2
Views: 2068
Reputation: 261
depending on the version you're using, instead of "ratio" you have to use "sampling_strategy" when you're using a dict.
Upvotes: 1
Reputation: 5
Try installing version 0.3
imblearn 0.2.1 does not support the dictionary. You will need to install it from the source.
pip install -U git+https://github.com/scikit-learn-contrib/imbalanced-learn.git
Upvotes: 0