Skip to main content

OQBoost 2.0 — gradient-boosted 2D-oblique decision trees (histogram-binned, C++ backend)

Project description

OQBoost 2.0

Gradient-boosted 2D-oblique decision trees — histogram-binned, C++ backend.

OQBoost splits on oblique hyperplanes over feature pairs (a·u + b·v < t) instead of axis-aligned thresholds, so diagonal and interaction boundaries are represented directly rather than as axis-aligned approximations. Version 2.0 is a histogram-binned 2D-oblique core that finds split directions by H-weighted least-squares regression of the gradient — deterministic, one 2×2 solve per feature pair (no random projections or numerical search).

scikit-learn compatible · compiled C++ (pybind11) + OpenMP · native missing-value handling (NaN routed to a learned bin, no imputation needed).


Install

pip install oqboost

Prebuilt wheels are provided for Windows, macOS (arm64), and Ubuntu/Linux via cibuildwheel. On other platforms pip builds from source — needs a C++17 compiler (clang++/g++) and, for parallelism, OpenMP (brew install libomp on macOS).

Quickstart

from oqboost import OQBoostClassifier, OQBoostRegressor

# Binary classification
clf = OQBoostClassifier(
    n_estimators=120, learning_rate=0.06, max_depth=4,
    max_bins=16, subsample=0.8, colsample=0.8, random_state=42,
)
clf.fit(X_train, y_train)
proba = clf.predict_proba(X_test)[:, 1]   # P(class 1)
pred  = clf.predict(X_test)

# Multiclass — pass a target with 3+ classes; handled one-vs-rest automatically
clf.fit(X_train, y_multiclass)
proba = clf.predict_proba(X_test)         # (n_samples, n_classes), rows sum to 1
labels = clf.predict(X_test)

# Regression (squared error)
reg = OQBoostRegressor(n_estimators=120, learning_rate=0.06)
reg.fit(X_train, y_train)
y_hat = reg.predict(X_test)

Both are drop-in scikit-learn estimators — usable in Pipeline, GridSearchCV, cross_val_score, and clone.

More features

# Imbalanced data: tune the decision threshold on a holdout (probabilities stay
# calibrated; "balanced" maximizes balanced accuracy, "f1" maximizes F1).
clf = OQBoostClassifier(threshold="balanced").fit(X_train, y_train)
clf.decision_threshold_          # the chosen cut

# Robust regression: huber / quantile losses (init = median), optional output clip.
reg = OQBoostRegressor(loss="huber", alpha=0.9, clip=True).fit(X_train, y_train)
q90 = OQBoostRegressor(loss="quantile", alpha=0.9).fit(X_train, y_train)  # 90th pctile

# Monotonic constraints (-1 / 0 / +1 per feature; list or {index: dir} dict),
# enforced through the oblique splits.
reg = OQBoostRegressor(monotone_constraints={0: +1, 3: -1}).fit(X_train, y_train)

# Incremental training: add trees without refitting from scratch.
clf = OQBoostClassifier(n_estimators=100, warm_start=True).fit(X_train, y_train)
clf.set_params(n_estimators=200).fit(X_train, y_train)   # trains only +100 trees

# Serialization: models are pickle / joblib compatible out of the box.
import pickle, joblib
pickle.dump(clf, open("clf.pkl", "wb"))
clf2 = pickle.load(open("clf.pkl", "rb"))
joblib.dump(clf, "clf.joblib")

# Native explanations (no SHAP dependency)
clf.feature_importances_         # Σ gain per feature
clf.coefficient_importances_     # Σ gain·|coef| (direction-weighted)
clf.interaction_importances_     # d×d matrix, Σ gain·|a|·|b| — learned feature pairs
phi = clf.explain(X_test)        # (n, n_features) additive contributions — binary / regression
                                 # phi.sum(axis=1) == raw prediction − base (like SHAP)

# Plots (pip install oqboost[plot])
import oqboost.plot as oqp
oqp.plot_importance(clf)              # gain / gain·|coef| bar
oqp.plot_interactions(clf)           # pairwise-interaction heatmap
oqp.plot_explanation(clf, x)         # one-sample additive contributions
oqp.plot_explanation_summary(clf, X) # SHAP-style beeswarm

Key hyperparameters

Param Default Meaning
n_estimators 120 boosting rounds
learning_rate 0.06 shrinkage
max_depth 4 interaction depth (stacked 2D cuts)
max_bins 16 grid / direction-seed resolution (keep small)
subsample 0.8 rows per tree (key overfit lever)
colsample 0.8 features per node
reg_lambda 1.0 L2 regularization
n_screen -1 SIS top-m feature screening (-1 = exhaustive)
threshold "0.5" binary decision cut — "balanced"/"f1" tunes it on a holdout (imbalanced data)
loss "squared" regression loss — "huber"/"quantile" are outlier-robust
alpha 0.9 huber δ-quantile / quantile target
clip False clamp regression output to training target range
monotone_constraints None per-feature monotonicity -1/0/+1 (list or {idx: dir} dict)
warm_start False add trees on top of the existing model when n_estimators grows (incremental)
categorical_features None indices / bool mask of categorical columns → lossless binning (no level merging)

Why oblique

Axis-aligned boosters need several stacked cuts to approximate a diagonal boundary, while an oblique split represents it directly. On 2D problems (XOR, Spiral, Checkerboard) OQBoost draws the diagonal boundary with oblique cuts rather than axis-aligned steps. On Optuna-tuned tabular benchmarks it is competitive with the established gradient-boosting libraries.

Full benchmarks, decision-boundary figures, and design notes: https://github.com/cree1116/oqboost-2.0

Note: OQBoost 2.0 is a ground-up rewrite. The original 1.x line — oblique splits via a Deterministic Gradient-Covariance Scan (DGCS) — lives at cree1116/OQBoost. 2.0 replaces the direction finder with a histogram-binned H-weighted gradient-regression fit (one 2×2 solve per pair).


MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oqboost-2.0.6.tar.gz (31.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

oqboost-2.0.6-cp313-cp313-win_amd64.whl (149.8 kB view details)

Uploaded CPython 3.13Windows x86-64

oqboost-2.0.6-cp313-cp313-manylinux_2_28_x86_64.whl (272.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

oqboost-2.0.6-cp313-cp313-macosx_14_0_arm64.whl (391.0 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

oqboost-2.0.6-cp312-cp312-win_amd64.whl (149.8 kB view details)

Uploaded CPython 3.12Windows x86-64

oqboost-2.0.6-cp312-cp312-manylinux_2_28_x86_64.whl (272.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

oqboost-2.0.6-cp312-cp312-macosx_14_0_arm64.whl (391.0 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

oqboost-2.0.6-cp311-cp311-win_amd64.whl (147.0 kB view details)

Uploaded CPython 3.11Windows x86-64

oqboost-2.0.6-cp311-cp311-manylinux_2_28_x86_64.whl (270.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

oqboost-2.0.6-cp311-cp311-macosx_14_0_arm64.whl (389.0 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

oqboost-2.0.6-cp310-cp310-win_amd64.whl (146.0 kB view details)

Uploaded CPython 3.10Windows x86-64

oqboost-2.0.6-cp310-cp310-manylinux_2_28_x86_64.whl (269.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

oqboost-2.0.6-cp310-cp310-macosx_14_0_arm64.whl (387.8 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

Details for the file oqboost-2.0.6.tar.gz.

File metadata

  • Download URL: oqboost-2.0.6.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oqboost-2.0.6.tar.gz
Algorithm Hash digest
SHA256 9bce745ca9e92231b035cddcad3ced9167a0ba1ee103e95b5fc4a614a8df3b0d
MD5 a861bfbcb4892e842b298ea9b981ae8e
BLAKE2b-256 5fd0eaafd9a00221f0319d4158c7476b3742e957c2140cc04127e89319041a72

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: oqboost-2.0.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 149.8 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oqboost-2.0.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f171b00d4f0d51ffe903bb62d6d112c7d0dc6046c6e601499b07ecc2de77fa34
MD5 e621bfb5beb88da6810ff1ade7760a84
BLAKE2b-256 c4b0ee57df60165a22a35ec0a029bb9cccc32a526bd8a2dfd40647257e53add8

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f4e7d00001265cd6c06abe873933d8d9272289229f0a7b4f01d7f376b420a314
MD5 f6f9bbac023c655df3621d92e84511a6
BLAKE2b-256 b651ccb2db12aeb0266a8e180deda9ce9d3910e383c118ad90718ac9f7765ed4

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 dfe3e7178a35521910893f1c4d890ab0d0d33eea461da1a76448ec1284813803
MD5 9be5ccba9bf8a9a1f31273cc1cc33c1d
BLAKE2b-256 4a02a969038a4bcd692bbc4d06d36a37c7a8e1ce60fb0fe4e45bcaf1368d91c1

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: oqboost-2.0.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 149.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oqboost-2.0.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ee83dbebbb0fb435e5187950647bc717163c31ba51de54b970e8a09af9f73468
MD5 0d3ce021a8ccd28c233bbeb687bbc206
BLAKE2b-256 a89933071f6cc2c2632145b522f733ffb98acffdf5adbd0b6d6f74fa966f25d2

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ef1de967d32eadcfcf10b1814c52c856a3616169759449228d79d3eefaa6741a
MD5 b9a6240b8f36abae1efe2336328d39b1
BLAKE2b-256 6a1b1220509434489d80d6c32840ddd90854133d05d1151fae92b8c210053684

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f5ed34723186df286812b48f3b9fddbad2e0a84c7fd69d45e228bd4a1c644866
MD5 4ad54c1e8a9b19aa7098d6141f5951b3
BLAKE2b-256 cd4c182c4ee8d3c62d9dc89694013aed801227faaca6265eb3c909bb7055c500

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: oqboost-2.0.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 147.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oqboost-2.0.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3eb424611574b8a59ea2a0096e603ca6789f6fc51a21f8026f9ca1b1a73212ec
MD5 79cafeeb79e0dd721e061a0fdfa2c4a1
BLAKE2b-256 66c1059dc25a86b58666196825d70bfd3f3eb2cb0d6cdeed2f0763c8dce23ac7

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 26b0928f689e9082e3b3d104b36ffb1c67229b00fde451dbcabf1d97008bc19a
MD5 492bb23544bbdfc175eb085516039fd3
BLAKE2b-256 e9a3b4cf875e315a2e0f5c55a5451d95b47e2ca6d709cd0a4f17be3736ee6952

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 c78e561b190562a3a8f0eb5ae897e256cfc4ed423326802a7f97f1f902e47fd0
MD5 b1c81ff11f08f521124c96f15699539a
BLAKE2b-256 ff77c6c04055fdc5419c1de77717fa460c963d866b99454b7eb3de45f4931b65

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: oqboost-2.0.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 146.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for oqboost-2.0.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6148c20861f25be79e18ac881806fc0ef7eb9a1cfff624fd7c348b7cf205709f
MD5 61887063a219e9a5e9c5cc4c690f734a
BLAKE2b-256 344f600452e7ba126946cc9ef0ea31fb24362439356b0dd4f440688a6da4674b

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 afc6ad7c2615a1bd6335de247f69bbe40a5ae19be7f9cf194f5e6d8818a9a0fb
MD5 b2bf78de2b69ab39d112ded3fa95b4fb
BLAKE2b-256 404adfff71f464955387005ec4302eb2cfa853684b4814b9ecfe9ae806c3ceca

See more details on using hashes here.

File details

Details for the file oqboost-2.0.6-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for oqboost-2.0.6-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 38ba945262af36571a7dc684b830e88689cba911ccd5deb4e2f27b9c7dc9de04
MD5 dbe9d43460fc4f7b753d93011c5ea40e
BLAKE2b-256 793e0a802da202ecf1abe8a76016f89a646b75c97e7b4eff2035f08e0479a5b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page