Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Scikit learn contrib Imbalanced learn EasyEnsembleClassifier

From Leeroopedia


Knowledge Sources
Domains Machine_Learning, Ensemble_Learning, Imbalanced_Learning
Last Updated 2026-02-09 03:00 GMT

Overview

Concrete tool for ensemble learning with per-learner under-sampling and AdaBoost provided by the imbalanced-learn library.

Description

The EasyEnsembleClassifier trains n_estimators AdaBoost classifiers, each on a balanced random under-sample. Uses RandomUnderSampler internally. A custom base estimator can be specified.

Usage

Import this class when you want an ensemble of AdaBoost learners, each trained on a different balanced view of the data.

Code Reference

Source Location

  • Repository: imbalanced-learn
  • File: imblearn/ensemble/_easy_ensemble.py
  • Lines: L34-294

Signature

class EasyEnsembleClassifier(BaseEnsemble):
    def __init__(
        self,
        n_estimators=10,
        estimator=None,
        *,
        warm_start=False,
        sampling_strategy="auto",
        replacement=False,
        n_jobs=None,
        random_state=None,
        verbose=0,
    ):

Import

from imblearn.ensemble import EasyEnsembleClassifier

I/O Contract

Inputs

Name Type Required Description
X {array-like, sparse matrix} of shape (n_samples, n_features) Yes Training features
y array-like of shape (n_samples,) Yes Target labels
n_estimators int No Number of AdaBoost learners (default: 10)

Outputs

Name Type Description
fit() returns self Fitted ensemble
predict() returns ndarray Predicted labels

Usage Examples

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from imblearn.ensemble import EasyEnsembleClassifier

X, y = make_classification(n_classes=2, weights=[0.1, 0.9], n_samples=1000, random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

ee = EasyEnsembleClassifier(n_estimators=10, random_state=0)
ee.fit(X_train, y_train)
print(f"Score: {ee.score(X_test, y_test):.3f}")

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment