EasyEnsembleClassifier<T>

Models & Types · AiDotNet.Classification.ImbalancedEnsemble

Easy Ensemble Classifier for extremely imbalanced datasets.

Inheritance: ClassifierBase<T> → EasyEnsembleClassifier<T>

For Beginners

Easy Ensemble is designed for highly imbalanced data. It creates multiple balanced subsets by undersampling the majority class, trains a base classifier (typically AdaBoost) on each subset, and combines their predictions.

How It Works

How it works:

  • Keep all minority class samples
  • For each subset: randomly undersample majority to match minority
  • Train an AdaBoost classifier on each balanced subset
  • Combine predictions using majority voting or averaging

Key advantages:

  • Handles extreme imbalance: Works well even with 100:1 or 1000:1 ratios
  • Uses all majority data: Through multiple subsets, all majority samples contribute
  • Reduces variance: Ensemble approach gives stable predictions

When to use:

  • Extremely imbalanced datasets (more than 10:1 ratio)
  • When you need high recall for the minority class
  • When losing some majority class accuracy is acceptable

References:

  • Liu, X.Y., Wu, J., & Zhou, Z.H. (2009). “Exploratory Undersampling for Class-Imbalance Learning”

Example

var features = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
var labels = new Vector<double>(new double[] { 0.0, 1.0, 0.0, 1.0 });
var newSample = new Matrix<double>(new double[,] { { 1.0, 2.0 }, { 3.0, 4.0 }, { 5.0, 6.0 }, { 7.0, 8.0 } });
// Use AiModelBuilder facade for easy ensemble classification
var builder = new AiModelBuilder<double, Matrix<double>, Vector<double>>()
    .ConfigureModel(new EasyEnsembleClassifier<double>());
            
var result = builder.Build(features, labels);
var prediction = result.Predict(newSample);

Constructors

Constructor Summary
EasyEnsembleClassifier(int nSubsets, int nEstimatorsPerSubset, int maxDepth, double learningRate, string samplingStrategy, bool softVoting, int? seed) Initializes a new instance of EasyEnsembleClassifier.

Methods

Method Summary
Dictionary<string, T> GetFeatureImportance() Gets feature importance based on weak learner usage.
IFullModel<T, Matrix<T>, Vector<T>> WithParameters(Vector<T> parameters) Creates a new instance with the specified parameters.
Vector<T> Predict(Matrix<T> input) Predicts class labels using the ensemble.
void Train(Matrix<T> x, Vector<T> y) Gets the model type.