# imbalanced-learn

> Source: https://aiwiki.ai/wiki/imbalanced-learn
> Updated: 2026-11-18
> Fact-checked: 2026-11-18
> Categories: Data Science, Developer Tools, Machine Learning, Open Source AI
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "imbalanced-learn." aiwiki.ai, 18 Nov 2026. https://aiwiki.ai/wiki/imbalanced-learn
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

**imbalanced-learn** (imported in Python as `imblearn`) is an open-source [Python](https://aiwiki.ai/wiki/python) library of resampling techniques for classification problems on [imbalanced datasets](https://aiwiki.ai/wiki/imbalanced_dataset), in which one class heavily outnumbers the others. It provides over-sampling methods such as [SMOTE](https://aiwiki.ai/wiki/smote) and ADASYN, under-sampling methods such as random under-sampling, Tomek links and NearMiss, combinations of the two, ensemble classifiers that balance each bootstrap sample, and metrics suited to imbalanced data.[1][9] The library follows the [scikit-learn](https://aiwiki.ai/wiki/scikit_learn) estimator API, belongs to the scikit-learn-contrib family of projects, and is distributed under the [MIT License](https://aiwiki.ai/wiki/mit_license).[1][5][22] It was described in a 2017 paper in the *Journal of Machine Learning Research* by Guillaume Lemaître, Fernando Nogueira and Christos K. Aridas.[1]

As of November 2026 the current release is 0.14.2, published on 7 June 2026.[6][7]

## History

According to the project's documentation, development began in August 2014 with Fernando Nogueira, and the early work focused on implementing SMOTE.[3] Guillaume Lemaitre, Dayvid Victor and Christos Aridas then joined, adding further under-sampling and over-sampling methods and reworking the API so that it was fully compatible with scikit-learn.[3] The scikit-learn-contrib project list names Lemaitre, Nogueira, Dayvid Oliveira and Aridas as maintainers.[4]

The earliest release with files on the Python Package Index, version 0.1.1, was uploaded in July 2016.[6] The three authors posted a description of the toolbox to [arXiv](https://aiwiki.ai/wiki/arxiv) on 21 September 2016,[2] and the paper appeared in volume 18 of the *Journal of Machine Learning Research* in 2017.[1] Its abstract sorts the implemented methods into four groups (under-sampling, over-sampling, combinations of the two, and ensemble learning) and states that the toolbox depended only on [NumPy](https://aiwiki.ai/wiki/numpy), [SciPy](https://aiwiki.ai/wiki/scipy) and scikit-learn.[1] The project asks users who publish work with it to cite this paper.[3][5]

The release notes for every version from 0.13.0 to 0.14.2 credit Lemaitre with that release's scikit-learn compatibility work (in 0.14.1 jointly with another contributor).[7] His EuroSciPy speaker profiles describe him as working at :probabl and as a core developer (2025) and core maintainer (2026) of both scikit-learn and imbalanced-learn.[26][27]

### Release history

The table lists selected releases. Dates are upload dates on PyPI; changes are taken from the project's release notes.

| Version | Date | Selected changes |
|---|---|---|
| 0.1.1 | 2016-07-09 | Earliest release with files on PyPI[6] |
| 0.2.0 | 2016-12-31 | Bug fixes to NearMiss, EasyEnsemble, AllKNN and Repeated ENN[6][7] |
| 0.3.0 | 2017-08-24 | User guide added; pytest replaces nose; benchmark dataset loader introduced[6][7][18] |
| 0.4.0 | 2018-10-12 | `fit_resample` replaces `fit_sample`; `sampling_strategy` replaces `ratio`; Keras and TensorFlow batch generators; BalancedRandomForestClassifier, EasyEnsembleClassifier, RUSBoostClassifier and SMOTENC added; last version to support Python 2.7[6][7] |
| 0.5.0 | 2019-06-28 | KMeansSMOTE added; Python 2 support removed[6][7] |
| 0.6.0 | 2019-12-05 | Old `BalanceCascade` and `EasyEnsemble` classes removed after deprecation[6][7] |
| 0.8.0 | 2021-02-18 | SMOTEN, ValueDifferenceMetric and macro-averaged mean absolute error added[6][7] |
| 0.8.1 | 2021-09-29 | Compatibility with scikit-learn 1.0[6][7] |
| 0.10.0 | 2022-12-09 | Feature-name support for all samplers; `n_jobs` deprecated in SMOTE-family samplers[6][7] |
| 0.12.0 | 2024-01-24 | SMOTENC and BorderlineSMOTE bug fixes; missing-value support in BalancedRandomForestClassifier[6][7] |
| 0.13.0 | 2024-12-20 | Compatibility with scikit-learn 1.6[6][7] |
| 0.14.0 | 2025-08-14 | InstanceHardnessCV splitter added; compatibility with scikit-learn 1.7[6][7] |
| 0.14.1 | 2025-12-21 | Compatibility with scikit-learn 1.8[6][7] |
| 0.14.2 | 2026-06-07 | Compatibility with scikit-learn 1.9; clearer SMOTENC encoder error[6][7] |

<figure class="embedvideo">
<iframe src="https://www.youtube-nocookie.com/embed/npSkuNcm-Og" title="Imbalanced-learn: regrets and onwards - with Guillaume Lemaitre, core-maintainer"></iframe>
<figcaption>"Imbalanced-learn: regrets and onwards - with Guillaume Lemaitre, core-maintainer", video from Probabl, published December 5, 2024. <a href="https://www.youtube.com/watch?v=npSkuNcm-Og">Watch on YouTube</a>.</figcaption>
</figure>

## Design and API

Samplers in imbalanced-learn are scikit-learn estimators with one extra method. Where a scikit-learn transformer implements `fit` and `transform`, an imbalanced-learn sampler implements `fit_resample(X, y)`, which returns a new feature matrix and a new label vector with a changed class distribution.[8] Inputs can be lists, NumPy arrays, [pandas](https://aiwiki.ai/wiki/pandas) DataFrames or SciPy sparse matrices. The guide notes that, unlike scikit-learn, the library returns a DataFrame when given a DataFrame; it also converts sparse input to compressed sparse row format before resampling.[8]

Most samplers take a `sampling_strategy` parameter that says how much to resample. A float sets the target ratio of minority to majority samples (binary problems only), a string such as `'minority'`, `'not majority'` or `'all'` picks which classes to resample, a dictionary gives the desired number of samples per class, and a callable computes that dictionary from the labels.[21] For SMOTE the default, `'auto'`, is equivalent to `'not majority'`.[21] Methods that rely on neighbourhoods accept scikit-learn nearest-neighbour objects, and since version 0.10 any object with a compatible interface is accepted, which the release notes say allows instances from the cuML library.[7]

## Resampling methods

### Over-sampling

Over-samplers add samples to the under-represented classes, such as the [minority class](https://aiwiki.ai/wiki/minority_class). `RandomOverSampler` duplicates existing samples drawn with replacement and can handle heterogeneous data, including strings; with its `shrinkage` parameter it instead produces a smoothed bootstrap, a technique also known as ROSE (Random Over-Sampling Examples).[10] SMOTE and ADASYN generate synthetic points by interpolation. For a sample $x_i$ and one of its $k$ nearest neighbours $x_{zi}$, a new sample is

$$x_{new} = x_i + \lambda \times (x_{zi} - x_i)$$

where $\lambda$ is a random number in $[0, 1]$, so the new point lies on the segment between the two.[10] The variants differ mainly in which $x_i$ they choose: plain SMOTE picks samples at random, Borderline-SMOTE uses samples it labels as "in danger" near the class boundary, SVM-SMOTE uses support vectors found by a [support vector machine](https://aiwiki.ai/wiki/support_vector_machine_svm), KMeans-SMOTE clusters the data with [k-means](https://aiwiki.ai/wiki/k-means) first, and ADASYN generates more samples around points whose neighbourhoods are dominated by other classes.[10] In multi-class problems SMOTE and ADASYN work one-versus-rest, while `RandomOverSampler` resamples each class independently.[10]

| Class | Approach | Source cited in the documentation |
|---|---|---|
| `RandomOverSampler` | Random duplication, optional smoothed bootstrap | Menardi and Torelli (2014)[19] |
| `SMOTE` | Interpolation between minority neighbours | Chawla et al. (2002)[19] |
| `ADASYN` | More synthetic samples in hard regions | He et al. (2008)[19] |
| `BorderlineSMOTE` | SMOTE on borderline samples (two kinds) | Han et al. (2005)[19] |
| `SVMSMOTE` | SMOTE guided by support vectors | Nguyen et al. (2009)[19] |
| `KMeansSMOTE` | Clustering before SMOTE | Last et al. (2017)[19] |
| `SMOTENC` | Mixed numerical and categorical features | Chawla et al. (2002)[19] |
| `SMOTEN` | Categorical features only, using the Value Difference Metric | Chawla et al. (2002); Stanfill and Waltz (1986)[15][19] |

`SMOTENC` handles data that mix continuous and categorical columns: the categories of a new sample are set to the most frequent category among its nearest neighbours rather than interpolated. The documentation warns that it is not designed for purely categorical data, for which `SMOTEN` exists.[10]

### Under-sampling

[Under-sampling](https://aiwiki.ai/wiki/undersampling) methods reduce the number of samples in the over-represented classes, typically the [majority class](https://aiwiki.ai/wiki/majority_class). The user guide divides them into prototype generation, which creates new representative samples, and prototype selection, which keeps a subset of the original ones.[11] Prototype selection is further split into controlled methods, which reduce a class to a number the user specifies, and cleaning methods, which remove noisy or easy-to-classify samples and leave the final count to the algorithm.[11]

| Class | Type | What it does |
|---|---|---|
| `ClusterCentroids` | Prototype generation | Replaces a class with [k-means](https://aiwiki.ai/wiki/k-means) centroids[11] |
| `RandomUnderSampler` | Controlled | Removes samples at random, optionally with replacement[11] |
| `NearMiss` (versions 1 to 3) | Controlled | Keeps majority samples chosen by distance heuristics to the minority class[11] |
| `InstanceHardnessThreshold` | Controlled (approximately) | Removes samples a classifier assigns low probability[11] |
| `TomekLinks` | Cleaning | Removes Tomek links, pairs of opposite-class nearest neighbours[11] |
| `EditedNearestNeighbours` | Cleaning | Removes samples whose neighbours mostly or all belong to another class[11] |
| `RepeatedEditedNearestNeighbours` | Cleaning | Repeats the edited nearest neighbours rule[11] |
| `AllKNN` | Cleaning | Repeats editing with a growing neighbourhood[11] |
| `CondensedNearestNeighbour` | Cleaning | Keeps samples misclassified by a 1-nearest-neighbour rule[11] |
| `OneSidedSelection` | Cleaning | Condensed nearest neighbour followed by Tomek link removal[11] |
| `NeighbourhoodCleaningRule` | Cleaning | Combines edited nearest neighbours with a 3-nearest-neighbour classifier[11] |

A Tomek link between samples $x$ and $y$ of different classes exists when, for every other sample $z$, $d(x, y) < d(x, z)$ and $d(x, y) < d(y, z)$, where $d$ is the distance between samples. By default `TomekLinks` removes only the majority-class member of each link.[11] The algorithms come from the nearest-neighbour editing literature, including Hart's condensed nearest neighbour rule (1968), Wilson's edited nearest neighbour rule (1972) and two 1976 papers by Ivan Tomek.[19]

### Combined methods

Because SMOTE can create noisy samples when it interpolates between outliers and inliers, the library offers two samplers that clean the result: `SMOTETomek` applies SMOTE and then removes Tomek links, and `SMOTEENN` applies SMOTE and then edited nearest neighbours. The documentation notes that `SMOTEENN` tends to remove more noisy samples than `SMOTETomek`.[12] Both follow work by Gustavo Batista and colleagues published in 2003 and 2004.[19]

### Ensemble classifiers

The `imblearn.ensemble` module provides classifiers that resample inside the ensemble rather than before it.[13] `BalancedBaggingClassifier` resamples each bootstrap sample of a [bagging](https://aiwiki.ai/wiki/bagging) ensemble and, since version 0.8, accepts any sampler, which lets it reproduce several published bagging variants.[7][13] `BalancedRandomForestClassifier` gives each tree of a [random forest](https://aiwiki.ai/wiki/random_forest) a balanced bootstrap sample, following Chen, Liaw and Breiman (2004). `RUSBoostClassifier` randomly under-samples before each [boosting](https://aiwiki.ai/wiki/boosting) iteration, following Seiffert et al. (2009). And `EasyEnsembleClassifier` bags [AdaBoost](https://aiwiki.ai/wiki/adaboost) learners trained on balanced bootstrap samples, following Liu, Wu and Zhou (2008).[13][19]

## Pipeline and data leakage

The library ships its own `Pipeline` class and `make_pipeline` function. The class accepts samplers as intermediate steps, and the samplers are applied only during `fit`, not when the pipeline predicts or scores.[20] This matters because resampling before splitting data into training and test sets is a common mistake. The documentation's "Common pitfalls" chapter gives two reasons: the test set no longer has the real class distribution, and a sampler that generates or selects samples using neighbouring points can use information from samples that later end up in the test set, a form of [data leakage](https://aiwiki.ai/wiki/data_leakage).[17]

The chapter illustrates the effect on a version of the adult census dataset made more imbalanced (about 1.1% positive). Resampling the whole dataset before [cross-validation](https://aiwiki.ai/wiki/cross-validation) produced a cross-validated balanced accuracy of 0.724 that fell to 0.698 on held-out data, while putting the sampler inside a `Pipeline` gave 0.732 in cross-validation and 0.727 on the held-out data.[17]

## Other components

| Module | Contents |
|---|---|
| `imblearn.metrics` | Sensitivity and specificity scores, geometric mean score, index balanced accuracy wrapper, macro-averaged mean absolute error for ordinal classification, and `classification_report_imbalanced`[9][15] |
| `imblearn.metrics.pairwise` | `ValueDifferenceMetric`, a distance for categorical features[15] |
| `imblearn.model_selection` | `InstanceHardnessCV`, a cross-validation splitter[16] |
| `imblearn.datasets` | `fetch_datasets` (27 benchmark datasets) and `make_imbalance`[18] |
| `imblearn.keras`, `imblearn.tensorflow` | Generators of balanced mini-batches for [Keras](https://aiwiki.ai/wiki/keras) and [TensorFlow](https://aiwiki.ai/wiki/tensorflow)[14] |
| `imblearn` | `FunctionSampler`, which turns a user-written function into a sampler[14] |

The user guide notes that scikit-learn offered only `balanced_accuracy_score` (added in scikit-learn 0.20) as a metric for imbalanced datasets, and that `imblearn.metrics` adds other metrics used in the literature.[15] The geometric mean score is the root of the product of the per-class sensitivities: for $C$ classes with sensitivities $s_1, \dots, s_C$, it is $(s_1 s_2 \cdots s_C)^{1/C}$, a measure that tries to maximise accuracy on each class while keeping those accuracies balanced.[15]

`InstanceHardnessCV`, added in version 0.14.0, spreads hard-to-classify samples evenly across folds.[7][16] The guide defines the instance hardness of a sample as $H(x) = 1 - P(\hat{y} \mid x)$, one minus the predicted probability of the most probable class, and recommends the splitter for model selection tasks such as hyperparameter tuning and feature selection, not for estimating the performance to expect in production.[16]

`fetch_datasets` downloads 27 binarised imbalanced datasets, mostly from the UCI repository with a few from LIBSVM and KDD sources.[18] The API documentation says it loads them from Zenodo.[29] Their imbalance ratios range from 8.6:1 (ecoli) to 130:1 (abalone_19).[18] `make_imbalance` turns a balanced dataset into an imbalanced one for experiments.[18]

## Installation and licensing

The package is published on PyPI as `imbalanced-learn` and on conda-forge, and is installed with `pip install -U imbalanced-learn` or `conda install -c conda-forge imbalanced-learn`.[5] Version 0.14.2 requires Python 3.10 or later, NumPy 1.25.2 or later, SciPy 1.11.4 or later and scikit-learn 1.4.2 or later; pandas, TensorFlow and Keras are optional.[5][6] The code is released under the MIT License, copyright "The imbalanced-learn developers".[22]

## Adoption

On 18 November 2026 the project's GitHub repository showed about 7.1 thousand stars,[5] and PyPI download statistics recorded about 6.0 million downloads of the package in the preceding month.[23] Researchers also use it as a baseline implementation: the 2022 study "To SMOTE, or not to SMOTE?" by Yotam Elor and Hadar Averbuch-Elor used imbalanced-learn for every over-sampler it tested except one, and added 24 datasets from the library's collection to its candidate pool.[24]

## Debate over resampling

The usefulness of the techniques the library implements has been questioned. Elor and Averbuch-Elor compared balancing methods with strong gradient-boosting classifiers ([LightGBM](https://aiwiki.ai/wiki/lightgbm), [XGBoost](https://aiwiki.ai/wiki/xgboost) and [CatBoost](https://aiwiki.ai/wiki/catboost)) as well as weaker learners. They reported that balancing helped weak classifiers but did not improve prediction performance for the strong ones.[24] In clinical risk prediction, Ruben van den Goorbergh and colleagues found in a 2022 study with [logistic regression](https://aiwiki.ai/wiki/logistic_regression) that random under-sampling, random over-sampling and SMOTE produced strongly miscalibrated models that overestimated the probability of the minority class, without improving discrimination. That study used R packages, not imbalanced-learn.[25]

Tutorials on imbalanced classification given by Lemaitre at EuroSciPy have covered these questions alongside resampling. The 2025 tutorial, with Olivier Grisel, examined resampling and how class imbalance affects probability estimates and calibration; the 2026 tutorial, with Anne Beyer, covered resampling strategies together with scikit-learn's calibration and decision-threshold tools, `CalibratedClassifierCV` and `TunedThresholdClassifierCV`.[26][27] `TunedThresholdClassifierCV` was added to scikit-learn in version 1.5 to choose the [decision threshold](https://aiwiki.ai/wiki/decision_threshold) of a binary classifier that optimises a given metric.[28]

## See also

- [SMOTE](https://aiwiki.ai/wiki/smote)
- [Oversampling](https://aiwiki.ai/wiki/oversampling)
- [Undersampling](https://aiwiki.ai/wiki/undersampling)
- [Imbalanced dataset](https://aiwiki.ai/wiki/imbalanced_dataset)
- [Minority class](https://aiwiki.ai/wiki/minority_class)
- [Majority class](https://aiwiki.ai/wiki/majority_class)
- [Scikit-learn](https://aiwiki.ai/wiki/scikit_learn)

## References

1. Lemaître, Guillaume; Nogueira, Fernando; Aridas, Christos K. "Imbalanced-learn: A Python Toolbox to Tackle the Curse of Imbalanced Datasets in Machine Learning". Journal of Machine Learning Research, 18(17):1-5, 2017. https://jmlr.org/papers/v18/16-365.html
2. Lemaitre, Guillaume; Nogueira, Fernando; Aridas, Christos K. "Imbalanced-learn: A Python Toolbox to Tackle the Curse of Imbalanced Datasets in Machine Learning". arXiv:1609.06570, 21 September 2016. https://arxiv.org/abs/1609.06570
3. The imbalanced-learn developers. "About us". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/about.html
4. scikit-learn-contrib. "scikit-learn-contrib" (project list README). GitHub. https://github.com/scikit-learn-contrib/scikit-learn-contrib
5. The imbalanced-learn developers. "scikit-learn-contrib/imbalanced-learn" (repository and README). GitHub, accessed 18 November 2026. https://github.com/scikit-learn-contrib/imbalanced-learn
6. Python Package Index. "imbalanced-learn" (release history and metadata). PyPI, accessed 18 November 2026. https://pypi.org/project/imbalanced-learn/
7. The imbalanced-learn developers. "Release history". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/whats_new.html
8. The imbalanced-learn developers. "1. Introduction". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/introduction.html
9. The imbalanced-learn developers. "API reference". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/references/index.html
10. The imbalanced-learn developers. "2. Over-sampling". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/over_sampling.html
11. The imbalanced-learn developers. "3. Under-sampling". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/under_sampling.html
12. The imbalanced-learn developers. "4. Combination of over- and under-sampling". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/combine.html
13. The imbalanced-learn developers. "5. Ensemble of samplers". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/ensemble.html
14. The imbalanced-learn developers. "6. Miscellaneous samplers". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/miscellaneous.html
15. The imbalanced-learn developers. "7. Metrics". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/metrics.html
16. The imbalanced-learn developers. "8. Cross validation". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/model_selection.html
17. The imbalanced-learn developers. "9. Common pitfalls and recommended practices". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/common_pitfalls.html
18. The imbalanced-learn developers. "10. Dataset loading utilities". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/datasets/index.html
19. The imbalanced-learn developers. "12. References". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/zzz_references.html
20. The imbalanced-learn developers. "Pipeline". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/references/generated/imblearn.pipeline.Pipeline.html
21. The imbalanced-learn developers. "SMOTE". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/references/generated/imblearn.over_sampling.SMOTE.html
22. The imbalanced-learn developers. "LICENSE". GitHub. https://github.com/scikit-learn-contrib/imbalanced-learn/blob/master/LICENSE
23. PyPI Stats. "imbalanced-learn: recent downloads". pypistats.org, accessed 18 November 2026. https://pypistats.org/api/packages/imbalanced-learn/recent
24. Elor, Yotam; Averbuch-Elor, Hadar. "To SMOTE, or not to SMOTE?". arXiv:2201.08528, 2022. https://arxiv.org/abs/2201.08528
25. van den Goorbergh, Ruben; van Smeden, Maarten; Timmerman, Dirk; Van Calster, Ben. "The harm of class imbalance corrections for risk prediction models: illustration and simulation using logistic regression". Journal of the American Medical Informatics Association, 29(9):1525-1534, 2022. https://doi.org/10.1093/jamia/ocac093
26. EuroSciPy 2025. "Predictive modeling for imbalanced classification using scikit-learn" (tutorial by Guillaume Lemaitre and Olivier Grisel). pretalx, 19 August 2025. https://pretalx.com/euroscipy-2025/talk/ASR3XL/
27. EuroSciPy 2026. "Deal with imbalanced classification using scikit-learn" (tutorial by Guillaume Lemaitre and Anne Beyer). pretalx, 22 July 2026. https://pretalx.com/euroscipy-2026/talk/D9FJAC/
28. scikit-learn developers. "Release Highlights for scikit-learn 1.5". scikit-learn documentation. https://scikit-learn.org/stable/auto_examples/release_highlights/plot_release_highlights_1_5_0.html
29. The imbalanced-learn developers. "fetch_datasets". imbalanced-learn documentation, version 0.14.2. https://imbalanced-learn.org/stable/references/generated/imblearn.datasets.fetch_datasets.html

