imbalance-xgboost
XGBoost for label-imbalanced data: XGBoost with weighted and focal loss functions
Decision gist · record as of 2026-08-14
Yes, if you need focal or weighted loss for XGBoost on imbalanced binary classification and are willing to test compatibility with your XGBoost version. The package has low install friction and permissive licensing. However, dormancy since 2021 means no active maintenance, so verify it works with your current environment before relying on it in production.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires xgboost >= 1.1.1 as of version 0.8.1; package was tested on Python 3.5 and 3.6 with incomplete testing on 3.7 and 3.8.
- Low friction installation with three core dependencies (numpy, scikit-learn, xgboost).
- Package is dormant—last release was in February 2021, so expect no active maintenance or updates.
License · maintenance · safety
MIT (permissive) — MIT license is permissive, allowing free use, modification, and distribution with minimal restrictions, making it safe for most projects.
last release 2021-02-08 (2013 days) · last repo commit 2024-02-14 · 341 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 151,179 downloads/mo, #10,940 on PyPI
Alternatives
Verify before relying
pip install imbalance-xgboost
from imbalance_xgboost import imbalance_xgboost
model = imbalance_xgboost(special_objective='focal')
model.fit(X_train, y_train)
predictions = model.predict_sigmoid(X_test)- Compatibility with Python versions beyond 3.8 and current XGBoost releases (last tested in early 2021).
- Whether early stopping feature (added in 0.8.1) works reliably with recent XGBoost versions.
- Real-world performance gains compared to XGBoost's native scale_pos_weight or other imbalance handling methods.
What it is and what it does
Imbalance-XGBoost is a wrapper around XGBoost that implements weighted and focal loss functions for binary classification on imbalanced datasets. The package handles the mathematical complexity of computing first and second-order gradients required by XGBoost's custom loss interface, so you can use these loss functions without deriving the math yourself. It exposes the loss choice via a `special_objective` parameter and allows tuning of the imbalance factor (α) and focal parameter (γ) at initialization.
The wrapper is designed to be compatible with scikit-learn's API, so you can use it with GridSearchCV and other sklearn utilities for hyperparameter tuning. It provides multiple prediction methods (raw logits, sigmoid probabilities, binary class labels, and two-class probability distributions) and includes evaluation functions for metrics like accuracy, precision, recall, F1, and confusion matrix components. However, the package has not been actively maintained since February 2021, and its compatibility with modern Python and XGBoost versions is untested.
Use it for
- Tuning focal loss hyperparameters (γ) on imbalanced binary datasets using GridSearchCV.
- Comparing weighted loss (α) versus focal loss on the same imbalanced classification problem.
- Integrating custom loss functions into scikit-learn pipelines and cross-validation workflows.
- Evaluating classification performance on imbalanced data using confusion matrix metrics.
- Training boosted models when one class is significantly underrepresented in the training set.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need focal or weighted loss for XGBoost on imbalanced binary classification and are willing to test compatibility with your XGBoost version.
The package has low install friction and permissive licensing. However, dormancy since 2021 means no active maintenance, so verify it works with your current environment before relying on it in production.
Install
imbalance-xgboost on PyPI
Before you install
Low friction installation with three core dependencies (numpy, scikit-learn, xgboost). Package is dormant—last release was in February 2021, so expect no active maintenance or updates.
Requires xgboost >= 1.1.1 as of version 0.8.1; package was tested on Python 3.5 and 3.6 with incomplete testing on 3.7 and 3.8.
License in practice
MIT license is permissive, allowing free use, modification, and distribution with minimal restrictions, making it safe for most projects.
Quickstart
pip install imbalance-xgboost
from imbalance_xgboost import imbalance_xgboost
model = imbalance_xgboost(special_objective='focal')
model.fit(X_train, y_train)
predictions = model.predict_sigmoid(X_test)
Verify before relying
- Compatibility with Python versions beyond 3.8 and current XGBoost releases (last tested in early 2021).
- Whether early stopping feature (added in 0.8.1) works reliably with recent XGBoost versions.
- Real-world performance gains compared to XGBoost's native scale_pos_weight or other imbalance handling methods.
Package facts
| License | MIT permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagesnumpyscikit-learnxgboost |
| Maintenance | Dormant 2,013 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 151,179 / month, #10,940 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6 |
Evidence: imbalance_xgboost-0.8.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “xgboost imbalanced data”
- imbalance-xgboostWraps XGBoost with weighted and focal loss functions to handle binary…
- imblearnThis package is a deprecated stub that redirects users to install…
- xgboost-rayDistributes XGBoost training and inference across multiple nodes and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also imbalanced-learn · xgboost-cpu · imblearn · xgboost · dtreeviz · catboost · pytorch-metric-learning · sklearn-crfsuite · xgboost-ray · geomloss