Imbalanced-learn
imbalanced-learn
A scikit-learn compatible library for handling class imbalance with resampling such as SMOTE and balanced ensemble methods.
Basic information
| Name | Imbalanced-learn |
|---|---|
| Full name | imbalanced-learn |
| Category | Machine Learning Frameworks & Libraries |
| Developer | The scikit-learn-contrib community |
| Release year | Not specified |
| Official website | imbalanced-learn.org |
| GitHub repository | scikit-learn-contrib/imbalanced-learn |
| Official documentation | Not specified |
| Package on PyPI | imbalanced-learn |
| License | MIT (Licence file) |
| Project status | Active Had a release in the last 12 months |
| Latest version | 7 June 2026 (version 0.14.2) |
| Programming language | Python |
| Operating systems | OS Independent (as declared by the package on PyPI) |
| Required Python version | >=3.10 |
| Difficulty level | Beginner |
Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)
Overview
imbalanced-learn provides methods to oversample the minority class (SMOTE, ADASYN and others), undersample the majority class and combine both, balanced ensemble classifiers, and metrics suited to imbalanced data.
It integrates with its own Pipeline, which ensures that resampling is applied only inside each cross-validation fold, avoiding data leakage, a common mistake in medical research.
When to choose it? Choose it when an important class is rare in tabular data, applying resampling only inside cross-validation.
Uses
Main uses
- Oversampling the rare class (SMOTE)
- Undersampling the majority class
- Balanced ensemble classifiers
Scientific fields
- Medicine and rare disease diagnosis
- Fraud detection
Suitable project types
- Classifying imbalanced medical data
- Detecting fraudulent transactions
Research applications
- Comparing resampling methods with correct cross-validation
Technical features
A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".
| CPU support | Supported |
|---|---|
| GPU support | Not supported |
| CUDA compatibility | Not supported |
| Distributed training or computing | Not supported |
| Automatic differentiation (Autodiff) | Not supported |
| Model deployment | Not applicable |
| Pre-trained models | Not applicable |
| Supported data types | NumPy arrays and pandas tables |
| Integration with other libraries | Scikit-learn, Pandas |
| Flexibility (editorial estimate) | Medium |
| Performance (editorial estimate) | Adequate |
| Community (editorial estimate) | Medium |
| Documentation quality (editorial estimate) | Good documentation |
Installation and running
pip install imbalanced-learnCompatibility: Python >=3.10 — according to the package data on PyPI, checked on 21 November 2026
Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.
Code examples
Examples marked "Run and tested" were actually run, with their output, test date and library versions recorded; the others need a GPU or model downloads, so they were not run in the test environment.
MediumSMOTE inside the pipeline without leakageRun and tested
Goal: Balancing classes on the training data only, in each fold.
from collections import Counter
from imblearn.over_sampling import SMOTE
from imblearn.pipeline import make_pipeline
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import StratifiedKFold, cross_val_score
X, y = make_classification(n_samples=2000, weights=[0.95, 0.05], n_features=10, random_state=0)
print("Class distribution:", {int(k): v for k, v in sorted(Counter(y).items())})
cv = StratifiedKFold(5, shuffle=True, random_state=0)
base = cross_val_score(LogisticRegression(max_iter=1000), X, y, cv=cv, scoring="recall")
smote = cross_val_score(make_pipeline(SMOTE(random_state=0), LogisticRegression(max_iter=1000)),
X, y, cv=cv, scoring="recall")
print(f"Recall of the rare class without balancing: {base.mean():.3f}")
print(f"Recall with SMOTE inside the pipeline: {smote.mean():.3f}")
Code explanation
SMOTE must not be applied before splitting, otherwise samples generated from the test data appear in training. The imbalanced-learn Pipeline applies resampling during fit only, so the validation fold keeps its real distribution.
Output recorded during testing
Class distribution: {0: 1892, 1: 108}
Recall of the rare class without balancing: 0.879
Recall with SMOTE inside the pipeline: 0.926This example was actually run and tested on 21 November 2026 on a CPU — imbalanced-learn 0.14.2, scikit-learn 1.9.1, python 3.13.18
Pros
- The same scikit-learn API
- Its Pipeline prevents data leakage when resampling
Limitations
- Resampling does not suit every problem and can generate unrealistic samples
- Designed mainly for tabular data
References and verification
- Package page on PyPI (source of the version, licence and release date) Checked directly
https://pypi.org/project/imbalanced-learn/
Checked on: 21 November 2026 — version checked: 0.14.2 — reviewed by: the DLArabic team
- Official website A link the package officially declares on PyPI
https://imbalanced-learn.org/
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official repository A link the package officially declares on PyPI
https://github.com/scikit-learn-contrib/imbalanced-learn
Checked on: 21 November 2026 — reviewed by: the DLArabic team
- Official licence file Checked directly
https://github.com/scikit-learn-contrib/imbalanced-learn/blob/master/LICENSE
Checked on: 21 November 2026 — reviewed by: the DLArabic team
History of verified versions
| Version | Release date | Checked on |
|---|---|---|
| 0.14.2 | 7 June 2026 | 21 November 2026 |
Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.
