Registry / ai-ml / imbalanced-learn

imbalanced-learn

JSON →
library0.14.2pypypi✓ verified 24d ago

A Python library for handling imbalanced datasets in machine learning, currently at version 0.14.1, with a release cadence of approximately every 6 months.

pip install imbalanced-learn
INSTALL
IMPORT
SIG · IMBALANCED-LEARN
I
imbalanced-learn
ai-mlpythonv0.14.2
Install
10.1s avg
Import
4374ms
Disk
283MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.14.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 10.1s · import 4.374s · 272MB
283MB installed
● package 283MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RandomOverSampler
from imblearn.over_sampling import RandomOverSampler
Ensure correct import path to avoid ImportError.

A quickstart example demonstrating the use of RandomOverSampler to balance an imbalanced dataset.

import numpy as np from imblearn.over_sampling import RandomOverSampler # Sample data X = np.array([[1, 2], [1, 3], [2, 3], [3, 4], [5, 6], [7, 8], [8, 9], [8, 10], [9, 10], [10, 11]]) y = np.array([0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) # Initialize RandomOverSampler ros = RandomOverSampler(random_state=42) # Fit and resample X_res, y_res = ros.fit_resample(X, y) print(f'Resampled dataset shape: {np.bincount(y_res)}')
Debug
Known issues
gotchaCompatibility issues with scikit-learn 1.6.0 and sklearn-compat 0.1.3 in imbalanced-learn 0.13.0.
fix
Upgrade to imbalanced-learn 0.14.1 or later.
affects: 0.13.0
gotchaImportError: cannot import name 'MultiOutputMixin' from 'sklearn.base'.
fix
Restart the Python kernel after installation to resolve import errors. ([stackoverflow.com](https://stackoverflow.com/questions/60254805/imbalanced-learn-import-error-cannot-import-name-multioutputmixin?utm_source=openai))
affects: All versions
gotchaImportError: cannot import name 'validate_data' from 'sklearn.utils.validation'.
fix
Upgrade to imbalanced-learn 0.14.1 or later. ([github.com](https://github.com/scikit-learn-contrib/imbalanced-learn/issues/1119?utm_source=openai))
affects: 0.13.0
breakingScikit-learn, a core dependency of imbalanced-learn, requires a C/C++ compiler for successful installation, which is typically not pre-installed in minimal base images like Alpine Linux. This results in 'Unknown compiler(s)' errors during metadata preparation.
fix
Ensure a C/C++ compiler toolchain is installed in the environment before attempting installation. For Alpine Linux, this typically involves `apk add build-base`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'imblearn'
The 'imbalanced-learn' library is not installed in the Python environment being used, or the environment is not correctly activated.
fix
Install the package using pip: `pip install imbalanced-learn` or with conda: `conda install -c conda-forge imbalanced-learn`.
AttributeError: 'SMOTE' object has no attribute 'fit_sample'
The method name `fit_sample` was deprecated and renamed to `fit_resample` in newer versions of imbalanced-learn (specifically, `fit_sample` was removed in version 0.8, having been aliased since 0.4).
fix
Replace `fit_sample()` with `fit_resample()` for all resampling objects, e.g., `X_resampled, y_resampled = SMOTE().fit_resample(X, y)`.
AttributeError: module 'imblearn' has no attribute 'ensemble'
When using `import imblearn`, the submodules (like `ensemble`, `over_sampling`, `under_sampling`) are not automatically imported into the top-level `imblearn` namespace.
fix
Explicitly import the desired submodule or class, for example, `from imblearn import ensemble` or `from imblearn.ensemble import EasyEnsembleClassifier`.
Upgrade
Version history
0.14.2latest on PyPI · released Jun 7, 2026
Audit
Dependencies
scikit-learnrequiredRequired for machine learning algorithms and tools.
numpyrequiredEssential for numerical computations.
scipyrequiredNeeded for scientific computations.
Agent activity
22 hits · last 30 days
node
20
Resources
imbalanced-learn — pip install imbalanced-learn · libregistry