'AttributeError: 'RandomOverSampler' object has no attribute 'fit_sample'
I am trying to use RandomOverSampler from imblearn but I'm getting error.
Looking at other posts, there seems to be a problem with older versions, but I checked my versions and I have:
sklearn.__version__
'0.24.1'
imblearn.__version__
'0.8.0'
This is the code I'm trying to run:
from imblearn.over_sampling import RandomOverSampler
OS = RandomOverSampler(sampling_strategy='auto', random_state=0)
osx, osy = OS.fit_sample(X, y)
And the error I get is:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-a080b92fc7bc> in <module>
2
3 OS = RandomOverSampler(sampling_strategy='auto', random_state=0)
----> 4 osx, osy = OS.fit_sample(X, y)
AttributeError: 'RandomOverSampler' object has no attribute 'fit_sample'
Solution 1:[1]
You want OS.fit_resample(X, y)
, not fit_sample
.
Solution 2:[2]
You want OS.fit_resample(X, y), not fit_resample.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tim Roberts |
Solution 2 | Alex |