Clear all

# SUP-4

0

After importing the imblearn on anacondo using

conda install -c conda-forge imbalanced-learn.I am getting the below error when calling RandomOverSampler(random_state=0)
AttributeError                            Traceback (most recent call last)
in
5 print("Before OverSampling, counts of label '0': {} n".format(sum(y_train==0)))
6 over_sample = RandomOverSampler(random_state=0)
----> 7 x_train_res, y_train_res = over_sample.fit_resample(x_train, y_train.ravel())
8 print("After OverSampling, counts of label '1': {}".format(sum(y_train_res==1)))
9 print("After OverSampling, counts of label '0': {} n".format(sum(y_train_res==0)))

D:\anaconda3\lib\site-packages\imblearn\base.py in fit_resample(self, X, y)
75         check_classification_targets(y)
76         arrays_transformer = ArraysTransformer(X, y)
---> 77         X, y, binarize_y = self._check_X_y(X, y)
78
79         self.sampling_strategy_ = check_sampling_strategy(

D:\anaconda3\lib\site-packages\imblearn\over_sampling\_random_over_sampler.py in _check_X_y(self, X, y)
77     def _check_X_y(self, X, y):
78         y, binarize_y = check_target_type(y, indicate_one_vs_all=True)
---> 79         X, y = self._validate_data(
80             X, y, reset=True, accept_sparse=["csr", "csc"], dtype=None,
81             force_all_finite=False,

AttributeError: 'RandomOverSampler' object has no attribute '_validate_data'

Did I miss out any other step for the installation of imblearn.  I have also tried running with the solution but I get the same error.Min Hui

0

I think this is an issue with the data being fed to fit_resample. Have you tried using the RandomOverSampler on the example code? Then you can adjust it from there and look for differences.

0

Hi,

I'm also facing the same problem as you. If you are using Jupyter Notebook via Anaconda, there is an issue with the version of SKlearn. The imbalanced-learn team on github is aware of this problem:

https://github.com/scikit-learn-contrib/imbalanced-learn/issues

Unfortunately, the solutions I can think of are quite messy and the best way is to wait for Anaconda to update their SKlearn library.

Share: