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 make index balanced accuracy

From Leeroopedia


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

Overview

Concrete tool for creating IBA-weighted scoring functions as a decorator factory provided by the imbalanced-learn library.

Description

The make_index_balanced_accuracy function is a decorator factory. It takes alpha and squared parameters and returns a decorator that wraps any scoring function to produce IBA-adjusted scores. Internally computes sensitivity and specificity via sensitivity_specificity_support and adjusts the metric by the dominance factor.

Usage

Import this function to wrap any scoring function (e.g., geometric_mean_score) with IBA adjustment. Apply as iba(alpha=0.1, squared=True)(scoring_func).

Code Reference

Source Location

  • Repository: imbalanced-learn
  • File: imblearn/metrics/_classification.py
  • Lines: L743-845

Signature

def make_index_balanced_accuracy(*, alpha=0.1, squared=True):
    """
    Args:
        alpha: float - Weighting factor for dominance (default: 0.1).
        squared: bool - Square the metric before weighting (default: True).
    Returns:
        callable - Decorator that wraps a scoring function with IBA adjustment.
    """

Import

from imblearn.metrics import make_index_balanced_accuracy

I/O Contract

Inputs

Name Type Required Description
alpha float No Dominance weighting factor (default: 0.1)
squared bool No Square the base metric (default: True)

Outputs

Name Type Description
decorator callable Decorator that wraps a scoring function to return IBA-weighted scores

Usage Examples

from imblearn.metrics import geometric_mean_score
from imblearn.metrics import make_index_balanced_accuracy

# Create IBA-weighted geometric mean
iba_gmean = make_index_balanced_accuracy(alpha=0.1, squared=True)(geometric_mean_score)

y_true = [1, 0, 0, 1, 0, 1]
y_pred = [0, 0, 1, 1, 0, 1]
score = iba_gmean(y_true, y_pred, average=None)
print(f"IBA G-mean: {score}")

Related Pages

Implements Principle

Requires Environment

Page Connections

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