External Libraries Based on scikit-learn#

yobx.sklearn.to_onnx() converts fitted estimators to ONNX from xgboost, lightgbm, category_encoders, and imbalanced-learn using the same registry-based architecture as the other yobx.sklearn converters.

Package

Module

category_encoders

yobx.sklearn.category_encoders

xgboost

yobx.sklearn.xgboost

lightgbm

yobx.sklearn.lightgbm

imbalanced-learn

yobx.sklearn.imblearn

Comparison: XGBoost vs LightGBM#

Both XGBoost and LightGBM are gradient-boosted tree libraries — their fitted models consist of an ensemble of binary decision trees. The converters map these trees to ONNX TreeEnsemble* operators and share the same high-level structure, differing only in how split conditions are expressed and how the raw margin is post-processed. The table below summarises the key differences between the converters for xgboost and lightgbm.

Property

XGBoost

LightGBM

Tree dump method

get_dump(dump_format='json')

booster_.dump_model()

Split direction (numerical)

x < threshold (BRANCH_LT)

x threshold (BRANCH_LEQ)

Categorical splits

Not supported by converter

Expanded to BRANCH_EQ chains

Base-score bias

Added from base_score cfg

None (baked into leaf values)

Regression transform

Identity / Sigmoid / Exp

Identity / Exp

Multi-class targets per round

n_classes trees

n_classes trees

Binary classifier raw outputs

1 tree per round (sigmoid)

1 tree per round (sigmoid)

imbalanced-learn#

imbalanced-learn extends scikit-learn with resampling techniques for imbalanced datasets. Resampling only happens at training time, so ONNX inference pipelines skip any step that exposes fit_resample and only convert the remaining transformers and the final estimator.

See yobx.sklearn.imblearn for the full API reference.