Examples — Version 0.11.0.dev0

# Examples

General-purpose and introductory examples for the `imbalanced-learn` toolbox.

# Examples showing API imbalanced-learn usage

Examples that show some details regarding the API of imbalanced-learn.

How to use sampling_strategy in imbalanced-learn

How to use sampling_strategy in imbalanced-learn

# Examples based on real world datasets

Examples which use real-word dataset.

Multiclass classification with under-sampling

Multiclass classification with under-sampling

Example of topic classification in text documents

Example of topic classification in text documents

Customized sampler to implement an outlier rejections estimator

Customized sampler to implement an outlier rejections estimator

Benchmark over-sampling methods in a face recognition task

Benchmark over-sampling methods in a face recognition task

Porto Seguro: balancing samples in mini-batches with Keras

Porto Seguro: balancing samples in mini-batches with Keras

Fitting model on imbalanced datasets and how to fight bias

Fitting model on imbalanced datasets and how to fight bias

## Examples using combine class methods

Combine methods mixed over- and under-sampling methods. Generally SMOTE is used for over-sampling while some cleaning methods (i.e., ENN and Tomek links) are used to under-sample.

Compare sampler combining over- and under-sampling

Compare sampler combining over- and under-sampling

# Dataset examples

Examples concerning the `imblearn.datasets` module.

Create an imbalanced dataset

Create an imbalanced dataset

## Example using ensemble class methods

Under-sampling methods implies that samples of the majority class are lost during the balancing procedure. Ensemble methods offer an alternative to use most of the samples. In fact, an ensemble of balanced sets is created and used to later train any classifier.

Bagging classifiers using sampler

Bagging classifiers using sampler

Compare ensemble classifiers using resampling

Compare ensemble classifiers using resampling

# Evaluation examples

Examples illustrating how classification using imbalanced dataset can be done.

Evaluate classification by compiling a report

Evaluate classification by compiling a report

Metrics specific to imbalanced learning

Metrics specific to imbalanced learning

# Model Selection

Examples related to the selection of balancing methods.

Plotting Validation Curves

Plotting Validation Curves

## Example using over-sampling class methods

Data balancing can be performed by over-sampling such that new samples are generated in the minority class to reach a given balancing ratio.

Sample generator used in SMOTE-like samplers

Sample generator used in SMOTE-like samplers

Effect of the shrinkage factor in random over-sampling

Effect of the shrinkage factor in random over-sampling

Compare over-sampling samplers

Compare over-sampling samplers

## Pipeline examples

Example of how to use the a pipeline to include under-sampling with `scikit-learn` estimators.

Usage of pipeline embedding samplers

Usage of pipeline embedding samplers

## Example using under-sampling class methods

Under-sampling refers to the process of reducing the number of samples in the majority classes. The implemented methods can be categorized into 2 groups: (i) fixed under-sampling and (ii) cleaning under-sampling.

Illustration of the definition of a Tomek link

Illustration of the definition of a Tomek link

Sample selection in NearMiss

Sample selection in NearMiss

Compare under-sampling samplers

Compare under-sampling samplers

Gallery generated by Sphinx-Gallery

previous

check_target_type

next

Examples showing API imbalanced-learn usage