Citation and evidence

imbalanced-learn

14 min full readUpdated 29 references

This article's verification

Report a problem with this article

Edit article
More

Cite this article

imbalanced-learn (imported in Python as imblearn) is an open-source Python library of resampling techniques for classification problems on imbalanced datasets, in which one class heavily outnumbers the others. It provides over-sampling methods such as 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 estimator API, belongs to the scikit-learn-contrib family of projects, and is distributed under the 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 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, 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.

VersionDateSelected changes
0.1.12016-07-09Earliest release with files on PyPI[6]
0.2.02016-12-31Bug fixes to NearMiss, EasyEnsemble, AllKNN and Repeated ENN[6][7]
0.3.02017-08-24User guide added; pytest replaces nose; benchmark dataset loader introduced[6][7][18]
0.4.02018-10-12fit_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.02019-06-28KMeansSMOTE added; Python 2 support removed[6][7]
0.6.02019-12-05Old BalanceCascade and EasyEnsemble classes removed after deprecation[6][7]
0.8.02021-02-18SMOTEN, ValueDifferenceMetric and macro-averaged mean absolute error added[6][7]
0.8.12021-09-29Compatibility with scikit-learn 1.0[6][7]
0.10.02022-12-09Feature-name support for all samplers; n_jobs deprecated in SMOTE-family samplers[6][7]
0.12.02024-01-24SMOTENC and BorderlineSMOTE bug fixes; missing-value support in BalancedRandomForestClassifier[6][7]
0.13.02024-12-20Compatibility with scikit-learn 1.6[6][7]
0.14.02025-08-14InstanceHardnessCV splitter added; compatibility with scikit-learn 1.7[6][7]
0.14.12025-12-21Compatibility with scikit-learn 1.8[6][7]
0.14.22026-06-07Compatibility with scikit-learn 1.9; clearer SMOTENC encoder error[6][7]

Expanded article table

"Imbalanced-learn: regrets and onwards - with Guillaume Lemaitre, core-maintainer", video from Probabl, published December 5, 2024. Watch on YouTube.

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 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. 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

xnew=xi+λ×(xzi−xi)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, KMeans-SMOTE clusters the data with 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]

ClassApproachSource cited in the documentation
RandomOverSamplerRandom duplication, optional smoothed bootstrapMenardi and Torelli (2014)[19]
SMOTEInterpolation between minority neighboursChawla et al. (2002)[19]
ADASYNMore synthetic samples in hard regionsHe et al. (2008)[19]
BorderlineSMOTESMOTE on borderline samples (two kinds)Han et al. (2005)[19]
SVMSMOTESMOTE guided by support vectorsNguyen et al. (2009)[19]
KMeansSMOTEClustering before SMOTELast et al. (2017)[19]
SMOTENCMixed numerical and categorical featuresChawla et al. (2002)[19]
SMOTENCategorical features only, using the Value Difference MetricChawla et al. (2002); Stanfill and Waltz (1986)[15][19]

Expanded article table

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 methods reduce the number of samples in the over-represented classes, typically the 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]

ClassTypeWhat it does
ClusterCentroidsPrototype generationReplaces a class with k-means centroids[11]
RandomUnderSamplerControlledRemoves samples at random, optionally with replacement[11]
NearMiss (versions 1 to 3)ControlledKeeps majority samples chosen by distance heuristics to the minority class[11]
InstanceHardnessThresholdControlled (approximately)Removes samples a classifier assigns low probability[11]
TomekLinksCleaningRemoves Tomek links, pairs of opposite-class nearest neighbours[11]
EditedNearestNeighboursCleaningRemoves samples whose neighbours mostly or all belong to another class[11]
RepeatedEditedNearestNeighboursCleaningRepeats the edited nearest neighbours rule[11]
AllKNNCleaningRepeats editing with a growing neighbourhood[11]
CondensedNearestNeighbourCleaningKeeps samples misclassified by a 1-nearest-neighbour rule[11]
OneSidedSelectionCleaningCondensed nearest neighbour followed by Tomek link removal[11]
NeighbourhoodCleaningRuleCleaningCombines edited nearest neighbours with a 3-nearest-neighbour classifier[11]

Expanded article table

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 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 a balanced bootstrap sample, following Chen, Liaw and Breiman (2004). RUSBoostClassifier randomly under-samples before each boosting iteration, following Seiffert et al. (2009). And EasyEnsembleClassifier bags 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.[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 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

ModuleContents
imblearn.metricsSensitivity 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.pairwiseValueDifferenceMetric, a distance for categorical features[15]
imblearn.model_selectionInstanceHardnessCV, a cross-validation splitter[16]
imblearn.datasetsfetch_datasets (27 benchmark datasets) and make_imbalance[18]
imblearn.keras, imblearn.tensorflowGenerators of balanced mini-batches for Keras and TensorFlow[14]
imblearnFunctionSampler, which turns a user-written function into a sampler[14]

Expanded article table

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, XGBoost and 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 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 of a binary classifier that optimises a given metric.[28]

Continue reading

More from See also

More to read

Topics:Data ScienceDeveloper ToolsMachine LearningOpen Source AI

References

  1. ^1 ^2 ^3 ^4 ^5Lemaî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. jmlr.org/...16-365
  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. arxiv.org/...1609.06570
  3. ^1 ^2 ^3The imbalanced-learn developers. "About us". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...about
  4. ^scikit-learn-contrib. "scikit-learn-contrib" (project list README). GitHub. github.com/...scikit-learn-contrib
  5. ^1 ^2 ^3 ^4 ^5The imbalanced-learn developers. "scikit-learn-contrib/imbalanced-learn" (repository and README). GitHub, accessed 18 November 2026. github.com/...imbalanced-learn
  6. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11 ^12 ^13 ^14 ^15 ^16 ^17Python Package Index. "imbalanced-learn" (release history and metadata). PyPI, accessed 18 November 2026. pypi.org/...imbalanced-learn
  7. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11 ^12 ^13 ^14 ^15 ^16 ^17 ^18The imbalanced-learn developers. "Release history". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...whats_new
  8. ^1 ^2The imbalanced-learn developers. "1. Introduction". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...introduction
  9. ^1 ^2The imbalanced-learn developers. "API reference". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...references
  10. ^1 ^2 ^3 ^4 ^5The imbalanced-learn developers. "2. Over-sampling". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...over_sampling
  11. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11 ^12 ^13 ^14The imbalanced-learn developers. "3. Under-sampling". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...under_sampling
  12. ^The imbalanced-learn developers. "4. Combination of over- and under-sampling". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...combine
  13. ^1 ^2 ^3The imbalanced-learn developers. "5. Ensemble of samplers". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...ensemble
  14. ^1 ^2The imbalanced-learn developers. "6. Miscellaneous samplers". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...miscellaneous
  15. ^1 ^2 ^3 ^4 ^5The imbalanced-learn developers. "7. Metrics". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...metrics
  16. ^1 ^2 ^3The imbalanced-learn developers. "8. Cross validation". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...model_selection
  17. ^1 ^2The imbalanced-learn developers. "9. Common pitfalls and recommended practices". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...common_pitfalls
  18. ^1 ^2 ^3 ^4 ^5The imbalanced-learn developers. "10. Dataset loading utilities". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...datasets
  19. ^1 ^2 ^3 ^4 ^5 ^6 ^7 ^8 ^9 ^10 ^11The imbalanced-learn developers. "12. References". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...zzz_references
  20. ^The imbalanced-learn developers. "Pipeline". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...imblearn.pipeline.Pipeline
  21. ^1 ^2The imbalanced-learn developers. "SMOTE". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...imblearn.over_sampling.SMOTE
  22. ^1 ^2The imbalanced-learn developers. "LICENSE". GitHub. github.com/...LICENSE
  23. ^PyPI Stats. "imbalanced-learn: recent downloads". pypistats.org, accessed 18 November 2026. pypistats.org/...recent
  24. ^1 ^2Elor, Yotam; Averbuch-Elor, Hadar. "To SMOTE, or not to SMOTE?". arXiv:2201.08528, 2022. arxiv.org/...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. doi.org/...ocac093
  26. ^1 ^2EuroSciPy 2025. "Predictive modeling for imbalanced classification using scikit-learn" (tutorial by Guillaume Lemaitre and Olivier Grisel). pretalx, 19 August 2025. pretalx.com/...ASR3XL
  27. ^1 ^2EuroSciPy 2026. "Deal with imbalanced classification using scikit-learn" (tutorial by Guillaume Lemaitre and Anne Beyer). pretalx, 22 July 2026. pretalx.com/...D9FJAC
  28. ^scikit-learn developers. "Release Highlights for scikit-learn 1.5". scikit-learn documentation. scikit-learn.org/...plot_release_highlights_1_5_0
  29. ^The imbalanced-learn developers. "fetch_datasets". imbalanced-learn documentation, version 0.14.2. imbalanced-learn.org/...rn.datasets.fetch_datasets

Improve this article

Add missing citations, update stale details, or write a clearer explanation. Anyone can edit: changes go live when you publish, and every edit is checked by an editor.

2 revisions · v2 · 2,776 words · full history

Fact-checks are independent of edits: a reviewer re-verifies the article against its sources and stamps the date. How we verify

Research and drafting on this wiki are AI-assisted, under named human editorial standards. How AI is used here

Reviewer note: Independent fact-check before publication on November 18, 2026: 115 claims checked against 33 cited and independent sources; 0 material and 3 minor corrections applied before publication.

Cite this page: AI Wiki. "imbalanced-learn." aiwiki.ai, updated 18 Nov 2026, fact-checked 18 Nov 2026. CC BY 4.0. https://aiwiki.ai/wiki/imbalanced-learn

Edit article