0

I have gotten stuck with importing RUSBoostClassifier following this example

from imblearn.ensemble import RUSBoostClassifier

I receive the following error:

ImportError                               Traceback (most recent call last)
<ipython-input-12-d0ff5157a81a> in <module>
----> 1 from imblearn.ensemble import RUSBoostClassifier
  2 from sklearn.datasets import make_classification
  3 
  4 X, y = make_classification(n_samples=1000, n_classes=3,
  5                            n_informative=4, weights=[0.2, 0.3, 0.5],

ImportError: cannot import name 'RUSBoostClassifier'

I do not understand why! I can easily use other modules from imblearn such as

from imblearn.under_sampling import RandomUnderSampler

or

from imblearn.over_sampling import SMOTE 

I use Jupyter notebook, the Python version is 3.6.6. I have updated sklearn package and reinstall imblearn package following this link.

Does anyone have any idea to solve this problem? Or have an idea to use directly this class (source code) in a code?

sophros
  • 14,672
  • 11
  • 46
  • 75
Amin Kiany
  • 722
  • 8
  • 17
  • Please post the complete error trace. Are you sure your Jupyter notebook runs in the same anaconda environment where `imblearn` is installed? – desertnaut Nov 13 '18 at 13:45
  • @desertnaut Thanks for the reply! About your question: I have only one anaconda environment. For this reason, I guess I run the Jupyter Notebook in the same anaconda environment where imblearn was installed. About the full Error message, I edited the post. You can see it there. – Amin Kiany Nov 13 '18 at 14:24
  • 1
    Still not quite sure about the environments; can you run a `!pip list` command in Jupyter and see if `imblearn` is indeed included in the installed packages? – desertnaut Nov 13 '18 at 14:47
  • 1
    Thanks for your hint. With your hint I saw that the version of the imblearn was 0.3.0 (although I have reinstalled the imblearn already!). New modules are supported in the latest version of imblearn (version 0.4.3). This time I removed completely the imblearn pakage and installed it again via Anaconda. After the installation I could successfully use all the modules in imblearn. – Amin Kiany Nov 13 '18 at 17:31
  • Cool! I suggest you post this as an answer, to help others in the future that may face similar situations... – desertnaut Nov 13 '18 at 17:38

1 Answers1

0

The problem was the version of imblearn package. New modules of imblearn such as RUSBoostClassifier or BalancedRandomForestClassifier are supported in version 0.4.3. The version of imblearn package can be checked with !pip list (thanks to @desertnaut). If you are using an old version, remove it completely (reinstalling the imblearn was not actually helpful for me). After that follow this instruction and install it in agin. In this case the latest version of imblearn will be added to your anaconda environment.

Amin Kiany
  • 722
  • 8
  • 17