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)        # additive contributions — (n, n_features) for binary/
                                 # regression, (n, n_classes, n_features) for multiclass
                                 # phi.sum(axis=-1) == raw score − 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)
max_lineage 0 LOB (experimental): >0 approximates high-order oblique interactions with only 2×2 solves — nodes inherit ancestor directions ((z,x)/(z,z) pairs) and compose them across depth. 0 = classic 2D

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.1.1.tar.gz (35.8 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.1.1-cp313-cp313-win_amd64.whl (159.7 kB view details)

Uploaded CPython 3.13Windows x86-64

oqboost-2.1.1-cp313-cp313-manylinux_2_28_x86_64.whl (282.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

oqboost-2.1.1-cp313-cp313-macosx_14_0_arm64.whl (401.9 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

oqboost-2.1.1-cp312-cp312-win_amd64.whl (159.7 kB view details)

Uploaded CPython 3.12Windows x86-64

oqboost-2.1.1-cp312-cp312-manylinux_2_28_x86_64.whl (282.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

oqboost-2.1.1-cp312-cp312-macosx_14_0_arm64.whl (401.8 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

oqboost-2.1.1-cp311-cp311-win_amd64.whl (156.9 kB view details)

Uploaded CPython 3.11Windows x86-64

oqboost-2.1.1-cp311-cp311-manylinux_2_28_x86_64.whl (280.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

oqboost-2.1.1-cp311-cp311-macosx_14_0_arm64.whl (399.7 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

oqboost-2.1.1-cp310-cp310-win_amd64.whl (156.1 kB view details)

Uploaded CPython 3.10Windows x86-64

oqboost-2.1.1-cp310-cp310-manylinux_2_28_x86_64.whl (279.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

oqboost-2.1.1-cp310-cp310-macosx_14_0_arm64.whl (398.5 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for oqboost-2.1.1.tar.gz
Algorithm Hash digest
SHA256 cd3e777a734827166d99cdc5ddf34cb5d193334a76ea83488c19f25f795c1686
MD5 433de471c5f9ce9830b446f85ac57b83
BLAKE2b-256 345f30ddba4045e395e64e99b5ad2d0b794b809d32a2424ce8b636143f0d1ed1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 159.7 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.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 43193d94fd50bbe238079cecb66f020f5763ce47a8d3da6f9f8672d1ffd9fdd3
MD5 abc58288f075016fcc25d7574a2e6c5c
BLAKE2b-256 1940731ffc1aa4112cf31b05f68dde0c938f12a038ba53b515d7178c5cc22344

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 758feb7be7960dff1b6b6b24318e1716c8528431b2f2fe587e4dbcd1cdb8d8d7
MD5 1563e4ba58f41a758a028dad256a1dd0
BLAKE2b-256 e51fa264216237610e25f4f07957d415f8e24a5024808463a542cb55a59d864c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 99b24d529cc3c86d582a981fce73ec3867e28d7e5fe23fe6fe903b115eabcf40
MD5 b3443359f465ad306553f09fac173020
BLAKE2b-256 b6b35838c0546551d7a0e04751c8e02ae8b72e8a35e0a4adb40b702d6df25971

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 159.7 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.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 909a555f365af8702be9e20c4695123a849bba9c490f8ddbb0335ce6d5c48dca
MD5 648e7ad13307e7daa604013b0cfec75b
BLAKE2b-256 d38075d80dd2931aeeb89ee81b274fe0c1a312e258e44c0d323136239c81c4d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 efcf1d016411cece7617a72bb3a9fed7b91145cc25490b15b83fc7f46a603d15
MD5 10981c18fabb20751dfd466522180059
BLAKE2b-256 95f2dd1a852dce7f9d5a252b11b1e678b4e0f3b109c84b7887308378bc64ef0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7db0e6a48f1c6374d92ed4681b263599497461608e9291f00b9e19eb74449a17
MD5 9dfd228aced3a501a6a2a22f6244ce5c
BLAKE2b-256 196cb49173f710c44c6aafb576a3265869e86e8b1e4a4db5a0c44f9d8dd814a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 156.9 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.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d42b7d1faf52d4a7c13ed1ad69a7bc03070e9188e000061d377ace7ac7e290b6
MD5 f719b3b20c0b9a0f09c01aaab9dda184
BLAKE2b-256 2e74a28bcd3c0d94a7c9cd9ba7251e9b2db0d74d43a1ffef61e0c003f55c5c93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2caa7e7ea03c582357c735c8af08f33c81a2da91365ff0e5b48a1047dd2a9a8f
MD5 8a506310695b9c44caf6f69eec58c03a
BLAKE2b-256 8bcdac670de551c488cf9f75edee85c910c588b8958482e152c542a4180eb04f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a7b01d95390700ce75d94e02de25a4cf08a9e6bee8cfba8c905ccf48dddd172f
MD5 a0bb6702bd217760f9971d721658287f
BLAKE2b-256 bca9649ca51665229f9d9c5909d9dba7c7ac749d5cfc6c0fe1bd5ebf5aa93961

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 156.1 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.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0e02965487ba9cc87878ac22f41ecfd5f7d63d6b8d6fcb1f82bca05a23a73a1c
MD5 34ed00edb398667b520d0fe3cedcf314
BLAKE2b-256 d3342b47f857c3dda4f16eb2942b665dd169d148dbb23bac4be1cdb1e3ba8dcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8ae99e852c0195649cc1de8c91373d1358e939734fa9d8885417e12fbf650f86
MD5 2e4ac7d17c47ab19d1c0afdaf83c7dd4
BLAKE2b-256 3cf35c1c8e860e33459b177e06762c2fd2cf633031eb73c6e387b7fc53a6a106

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9af07d4336ea86b8031cce583036b477f4f76bf86142a7c64749dc926fcc67fa
MD5 61eca8d9b17494209170563edfa7f641
BLAKE2b-256 d5b6f5a4c9a1958e57abf17d84f11c0136353020c821204585a8bbf31164bd29

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