--- id: imbalance-xgboost version: "0.8.1" license: MIT license_treatment: permissive maintenance: dormant --- # imbalance-xgboost — XGBoost for label-imbalanced data: XGBoost with weighted and focal loss functions License: permissive · Maintenance: dormant · Downloads: 151.2K/mo ## 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 above — verify before relying. Wraps XGBoost with weighted and focal loss functions to handle binary classification on imbalanced datasets, computing the required gradients automatically. 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 pip install imbalance-xgboost uv add imbalance-xgboost poetry add imbalance-xgboost ## Installing imbalance-xgboost 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. 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) 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. 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: unspecified - Install friction: low - Maintenance: dormant - Downloads: 151.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags xgboost imbalanced data, focal loss binary classification, weighted loss xgboost, class imbalance handling, xgboost custom loss function, imbalanced dataset classifier, xgboost label imbalance, imbalanced-classification, gradient-boosting, sklearn-compatible [View on SkillFed](https://skillfed.io/packages/imbalance-xgboost) · [View on PyPI](https://pypi.org/project/imbalance-xgboost/)