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.2.0.tar.gz (38.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.2.0-cp313-cp313-win_amd64.whl (166.4 kB view details)

Uploaded CPython 3.13Windows x86-64

oqboost-2.2.0-cp313-cp313-manylinux_2_28_x86_64.whl (291.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

oqboost-2.2.0-cp313-cp313-macosx_14_0_arm64.whl (409.6 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

oqboost-2.2.0-cp312-cp312-win_amd64.whl (166.3 kB view details)

Uploaded CPython 3.12Windows x86-64

oqboost-2.2.0-cp312-cp312-manylinux_2_28_x86_64.whl (291.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

oqboost-2.2.0-cp312-cp312-macosx_14_0_arm64.whl (409.6 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

oqboost-2.2.0-cp311-cp311-win_amd64.whl (163.3 kB view details)

Uploaded CPython 3.11Windows x86-64

oqboost-2.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (289.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

oqboost-2.2.0-cp311-cp311-macosx_14_0_arm64.whl (407.7 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

oqboost-2.2.0-cp310-cp310-win_amd64.whl (162.3 kB view details)

Uploaded CPython 3.10Windows x86-64

oqboost-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (287.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

oqboost-2.2.0-cp310-cp310-macosx_14_0_arm64.whl (406.3 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: oqboost-2.2.0.tar.gz
  • Upload date:
  • Size: 38.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.2.0.tar.gz
Algorithm Hash digest
SHA256 8c0556fcd4c072ba33ae687d9d87957842cb11b8642db6cf7463cfb011880d4d
MD5 204d9c635d2350d31ffca622c766176e
BLAKE2b-256 086f34cf20e89de85d824c11eefbb52a4608979c61999f6ee0df33f8020e417c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 166.4 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.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8642680fd5f9e66f3fd20d0717220324d46b810d2bf3d98185f505297474e19b
MD5 ddbbb8c79d972da3386b737579f1ef01
BLAKE2b-256 348ea1b0d3652a94c7af7831682bd9e3c16ebad30b5ff3d1433ff95a8a608d09

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc3f4021e311aefb52ec061317311425a168f6dbf738caf6c4247a595ed23e28
MD5 a6aff92091f8b0c26a085d7133fa186f
BLAKE2b-256 46f53de58c21966b51f803e1738341a3c2f37d311216a3a4a1e7f491388f7f8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 02ccbc1c97d60b7f06ef724bc5c944e8c37aaf5beb345dcefa4f543dda9bf2e5
MD5 0483027abdc99db26189b3aa9835bd5b
BLAKE2b-256 8ae96c0b98eb5b048520e48febf459c70c67cce401c2cdc2e0d5cee5f99a3550

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 166.3 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.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a83f9a3abc701ac045da5ee3957c11e48c40551573671e564faf4e2751c2fdd4
MD5 53877de9c874dffc2877c7ac050604e1
BLAKE2b-256 f1dbeaa8cb54408556748809170cdc04e0c197d9553c19732889fe9ebf482064

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 29cba5804397a97cc6d19a1e3b59caad140acc31ee62e88977a29597b3a08dad
MD5 60179c0c09ea4cbe6d30f266455c89f2
BLAKE2b-256 5d14cdc69f4256d68710c5536741ea9cb465d5009a6d20aaee12559dca1a7758

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 bf45ed72d3e0d41cd596210f15fbe803776dd81d26a414689d6c1f25ab7a1cfe
MD5 77102bee7ff068e4aabf7ec15b5a300c
BLAKE2b-256 1112d8c4a87e7dd8f47054190f64742266a9291e2de2767bcdb2e8e0b0502db9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 163.3 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.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 95fd112d5f6c09d87f7b8dbb4d41cf2239f48828d8307228a6597403c632af26
MD5 4e3bba63e65a24194824f3df8cf555c7
BLAKE2b-256 f0e2c3ce4108dc6fafa64ad22c921ceb3864e71921e327fb6505e33750e6b7a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3e362ee4009d4e947e97b70f84273c92a92a0caedb772820571e0e0a6add5a4
MD5 4e9ffb78d6132096c1d328f2a80e1a8c
BLAKE2b-256 894ad7894d076b56a30072d76741d980a8fc200ded2299699f3cc481b5e73431

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 22fec85c748375a3b9d42aaa3175fadc84c5ddece4598db60695e923126b5c59
MD5 55fa06104b0704432baa30e43314ffee
BLAKE2b-256 c2812fdd12097ef0215a9a13079486acf92975edb97a9e12b1f0a1708a590a14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 162.3 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.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e0efe49a5f0444fdea93e5fdf19bf54c62b96529ba078fa4092ed96dcfc953a1
MD5 17b3365693ac220df6cbe62f0ec6a858
BLAKE2b-256 c838074e1973ef98e4e9d832a6c0a08db32216ad1f94595e8992d07cee5c25bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 117adca06da2aaca015e6d8a7027ce893efad86f47ac489e764ab2f0811ba0ca
MD5 e8f316bd011353d7ff570fbc8dc64232
BLAKE2b-256 bd0c572d8ce945aa68c0ac5c25aa09151865039325387b0e911c1e54889e2729

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.2.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 362379278a96292608e5c80e99290920336a271716fb08d36b4b24f6a3af27a8
MD5 3a9824dd21b220b10f90c68ea6dcca71
BLAKE2b-256 0c8a74d7fdcf7ee07cff78d1480800c589d147c0b98943b667073deb2d0de42d

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