How to Fix AttributeError: ‘RandomUnderSampler’ object has no attribute ‘fit_resample’

Diagram of RandomUnderSampler object has no attribute fit_resample

Diagram

AttributeError: ‘RandomUnderSampler’ object has no attribute ‘fit_resample’ error occurs because you are using an “older version of imbalanced-learn”. The “fit_resample” attribute was introduced in version 0.8 of the imbalanced-learn library, but you are using an older version.

How to fix it?

To fix the AttributeError: ‘RandomUnderSampler’ object has no attribute ‘fit_resample’ error, “upgrade the imbalanced-learn package.”

pip install --upgrade imbalanced-learn

Once you have updated your version of the imbalanced-learn library, you should be able to use the “fit_resample” attribute without errors.

Here is a table of the versions of the imbalanced-learn library that support the “fit_resample” attribute:

Version Support for “fit_resample()”
0.8 and higher Yes
0.7 and lower No

I hope this helps! Let me know if you have any other questions.

Related posts

AttributeError: ‘SMOTE’ object has no attribute ‘fit_sample’

AttributeError: ‘Simple_Imputer’ object has no attribute ‘fill_value_categorical’

AttributeError: ‘Pipeline’ object has no attribute ‘fit_resample’

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.