UndersamplingBase<T>

Base Classes · AiDotNet.Preprocessing.ImbalancedLearning

Base class for undersampling strategies that reduce majority class samples.

Implements: IResamplingStrategy<T>

Known derived types: NearMiss<T>, RandomUnderSampler<T>

For Beginners

If you have 1000 “normal” samples and 50 “fraud” samples, undersampling might reduce the “normal” samples to 50-100 to balance the classes.

Advantages of undersampling:

  • Reduces training time (fewer samples)
  • Simpler than synthetic generation
  • Works well with large datasets

Disadvantages:

  • Loses potentially useful information
  • Can underfit if too aggressive
  • Not suitable for small datasets

Different undersampling strategies choose which samples to remove:

  • Random: Remove majority samples randomly
  • Tomek Links: Remove majority samples that form Tomek links with minority
  • ENN: Remove samples misclassified by nearest neighbors
  • NearMiss: Keep majority samples closest to minority samples

How It Works

Undersampling strategies reduce the number of majority class samples to achieve a more balanced dataset. Unlike oversampling, no synthetic samples are created.

Properties

Property Summary
string Name { get; } Gets the name of this undersampling strategy.

Methods

Method Summary
ResamplingStatistics<T> GetStatistics() Gets statistics about the last resampling operation.
ValueTuple<Matrix<T>, Vector<T>> Resample(Matrix<T> x, Vector<T> y) Resamples the dataset by removing majority samples.