Skip to content

[BUG] AttributeError: 'RandomOverSampler' object has no attribute '_check_n_features' #1142

@janas-adam

Description

@janas-adam

Describe the bug

came across the AttributeError: 'RandomOverSampler' object has no attribute '_check_n_features' while resampling.

Steps/Code to Reproduce

from imblearn.over_sampling import RandomOverSampler

sampler = RandomOverSampler(random_state=1)
X_resampled, y_resampled = sampler.fit_resample(X, y)

Actual Results

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[27], line 2
      1 sampler = RandomOverSampler(random_state=1)
----> 2 X_resampled, y_resampled = sampler.fit_resample(X, y)

imblearn/base.py:208, in BaseSampler.fit_resample(self, X, y)
    187 """Resample the dataset.
    188 
    189 Parameters
   (...)    205     The corresponding label of `X_resampled`.
    206 """
    207 self._validate_params()
--> 208 return super().fit_resample(X, y)

imblearn/base.py:106, in SamplerMixin.fit_resample(self, X, y)
    104 check_classification_targets(y)
    105 arrays_transformer = ArraysTransformer(X, y)
--> 106 X, y, binarize_y = self._check_X_y(X, y)
    108 self.sampling_strategy_ = check_sampling_strategy(
    109     self.sampling_strategy, y, self._sampling_type
    110 )
    112 output = self._fit_resample(X, y)

imblearn/over_sampling/_random_over_sampler.py:159, in RandomOverSampler._check_X_y(self, X, y)
    157 y, binarize_y = check_target_type(y, indicate_one_vs_all=True)
    158 X = _check_X(X)
--> 159 self._check_n_features(X, reset=True)
    160 self._check_feature_names(X, reset=True)
    161 return X, y, binarize_y

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

Versions

"imbalanced-learn>=0.12.4"
"scikit-learn>=1.7.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions