Skip to main content
QUICK REVIEW

[Paper Review] Imbalance-XGBoost: Leveraging Weighted and Focal Losses for Binary Label-Imbalanced Classification with XGBoost

Chen Wang, Chengyuan Deng|arXiv (Cornell University)|Aug 5, 2019
Imbalanced Data Classification TechniquesComputer Science15 citations
TL;DR

This paper introduces Imbalance-XGBoost, a Python package that integrates weighted cross-entropy and focal loss into XGBoost for binary label-imbalanced classification. By deriving and implementing first- and second-order gradients of these loss functions, the method achieves superior performance on imbalanced datasets, significantly improving F1-score and MCC over vanilla XGBoost, especially at high imbalance ratios.

ABSTRACT

The paper presents Imbalance-XGBoost, a Python package that combines the powerful XGBoost software with weighted and focal losses to tackle binary label-imbalanced classification tasks. Though a small-scale program in terms of size, the package is, to the best of the authors' knowledge, the first of its kind which provides an integrated implementation for the two losses on XGBoost and brings a general-purpose extension on XGBoost for label-imbalanced scenarios. In this paper, the design and usage of the package are described with exemplar code listings, and its convenience to be integrated into Python-driven Machine Learning projects is illustrated. Furthermore, as the first- and second-order derivatives of the loss functions are essential for the implementations, the algebraic derivation is discussed and it can be deemed as a separate algorithmic contribution. The performances of the algorithms implemented in the package are empirically evaluated on Parkinson's disease classification data set, and multiple state-of-the-art performances have been observed. Given the scalable nature of XGBoost, the package has great potentials to be applied to real-life binary classification tasks, which are usually of large-scale and label-imbalanced.

Motivation & Objective

  • To address the performance degradation of XGBoost in binary label-imbalanced classification tasks.
  • To implement weighted cross-entropy and focal loss functions within the XGBoost framework using analytical derivatives.
  • To provide a general-purpose, scalable solution for real-world imbalanced classification problems.
  • To demonstrate the effectiveness of the proposed loss functions through empirical evaluation on multiple benchmark datasets.
  • To release a lightweight, open-source Python package compatible with Scikit-learn and XGBoost.

Proposed method

  • The package integrates weighted cross-entropy and focal loss functions into XGBoost via a custom loss framework using derived first- and second-order gradients.
  • The method modifies the XGBoost objective function by incorporating class-weighted or focal loss terms to penalize misclassification of minority class instances more heavily.
  • Analytical derivations of the first- and second-order derivatives of both loss functions are provided, enabling efficient optimization in the gradient boosting framework.
  • The implementation is built on XGBoost with dependencies on NumPy and Scikit-learn, ensuring compatibility and ease of use.
  • The package supports hyperparameter tuning via grid search and is designed for scalability on large-scale datasets.
  • The approach is evaluated using 5-fold cross-validation on four UCI benchmark datasets with increasing imbalance ratios.

Experimental results

Research questions

  • RQ1Can integrating weighted and focal loss functions into XGBoost significantly improve performance on binary label-imbalanced classification tasks?
  • RQ2How do the derived first- and second-order gradients of the loss functions enable effective optimization within the XGBoost framework?
  • RQ3Does the proposed method outperform vanilla XGBoost in terms of F1-score and Matthews Correlation Coefficient on highly imbalanced datasets?
  • RQ4How does the performance of the method scale with increasing imbalance ratios across diverse benchmark datasets?
  • RQ5Can the package be effectively used in real-world applications with large-scale, imbalanced data?

Key findings

  • On the Parkinson’s disease dataset, both weighted- and focal-XGBoost achieved higher AUC and PR curve areas than vanilla XGBoost, indicating better minority class detection.
  • On the ecoli dataset (9:1 imbalance), weighted- and focal-XGBoost improved F1-score from 0.627 (vanilla XGBoost) to 0.645, with MCC rising from 0.586 to 0.616.
  • On the arrhythmia dataset (17:1 imbalance), F1-score increased from 0.627 to 0.681, and MCC from 0.605 to 0.665 with weighted-XGBoost.
  • On the ozone dataset (42:1 imbalance), F1-score improved from 0.144 (vanilla XGBoost) to 0.268 with weighted-XGBoost, and to 0.180 with focal-XGBoost.
  • The performance gains of the proposed methods became more pronounced as imbalance ratios increased, especially in F1-score and MCC metrics.
  • The package demonstrated competitive performance across all five datasets and is available on PyPI and GitHub, indicating practical usability and adoption potential.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.