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 RUSBoostClassifier

From Leeroopedia


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

Overview

Concrete tool for boosting with per-iteration random under-sampling provided by the imbalanced-learn library.

Description

The RUSBoostClassifier extends sklearn.ensemble.AdaBoostClassifier by applying RandomUnderSampler at each boosting iteration before training the weak learner. Supports custom base estimators and learning rate.

Usage

Import this class as a drop-in replacement for AdaBoostClassifier when dealing with imbalanced data.

Code Reference

Source Location

  • Repository: imbalanced-learn
  • File: imblearn/ensemble/_weight_boosting.py
  • Lines: L30-414

Signature

class RUSBoostClassifier(AdaBoostClassifier):
    def __init__(
        self,
        estimator=None,
        *,
        n_estimators=50,
        learning_rate=1.0,
        algorithm="deprecated",
        sampling_strategy="auto",
        replacement=False,
        random_state=None,
    ):

Import

from imblearn.ensemble import RUSBoostClassifier

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 boosting stages (default: 50)
learning_rate float No Shrinkage factor (default: 1.0)

Outputs

Name Type Description
fit() returns self Fitted boosted classifier
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 RUSBoostClassifier

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)

rusboost = RUSBoostClassifier(n_estimators=50, random_state=0)
rusboost.fit(X_train, y_train)
print(f"Score: {rusboost.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