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.0.tar.gz (35.3 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.0-cp313-cp313-win_amd64.whl (159.2 kB view details)

Uploaded CPython 3.13Windows x86-64

oqboost-2.1.0-cp313-cp313-manylinux_2_28_x86_64.whl (281.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

oqboost-2.1.0-cp313-cp313-macosx_14_0_arm64.whl (401.7 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

oqboost-2.1.0-cp312-cp312-win_amd64.whl (159.1 kB view details)

Uploaded CPython 3.12Windows x86-64

oqboost-2.1.0-cp312-cp312-manylinux_2_28_x86_64.whl (281.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

oqboost-2.1.0-cp312-cp312-macosx_14_0_arm64.whl (401.7 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

oqboost-2.1.0-cp311-cp311-win_amd64.whl (156.5 kB view details)

Uploaded CPython 3.11Windows x86-64

oqboost-2.1.0-cp311-cp311-manylinux_2_28_x86_64.whl (279.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

oqboost-2.1.0-cp311-cp311-macosx_14_0_arm64.whl (399.6 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

oqboost-2.1.0-cp310-cp310-win_amd64.whl (155.6 kB view details)

Uploaded CPython 3.10Windows x86-64

oqboost-2.1.0-cp310-cp310-manylinux_2_28_x86_64.whl (277.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

oqboost-2.1.0-cp310-cp310-macosx_14_0_arm64.whl (398.4 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: oqboost-2.1.0.tar.gz
  • Upload date:
  • Size: 35.3 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.0.tar.gz
Algorithm Hash digest
SHA256 c1b24bd6c6fb4aea277c2727063f219035a653adac930f5391b0aa8cc0f3b727
MD5 992849b6eaa4f944ea770c9c1698fd4e
BLAKE2b-256 c504ddcb85ed3b5bab18961704001fca73186072ba9477aea34a05c1263593d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 159.2 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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2b9d8ab6d47df67ee486b857b78c8b6ef5bc98d5321b67a19ac3b553d1e07498
MD5 3ee2767829d208b74243d271ed4a2f66
BLAKE2b-256 33aafe9755871d0cc52f04142188484fe31a75f35259baf0efb6706d9cd6edb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e97d6e8146905904dbd0c614a0f2410c1dcec428ce820d076f2b696adefcec8
MD5 1c06e3831e6b9fdb130f9f15d87ea07a
BLAKE2b-256 6974ced5b51faad0b4c0e6524f4c400178020b003f2408419449b7a1fe614ddc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 03f4ac447850c7a9f15b36c4655ed7e90cd3a59af1201eee630cc89e0af48050
MD5 c0fdf4c3b03761cbd619aa001e43ff02
BLAKE2b-256 edb160e5b7d43ed083bcca914caff85bb12409617c8bf3470247b7894530b3c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 159.1 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7143ea96fdec58fc55fbb592249335d596dff58a376290f05cf571b040598de2
MD5 60a61e138e0c41492df627ce61ba2980
BLAKE2b-256 6ebc51ffafa7edee367414d0ebd13d1f9deb2498bb10f766b9400ba53200882f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 893222e1c70a6f4bb204a03fca58ddd35f6cf60514a7ce0e3e1e4b1cd53a0313
MD5 f746b2363c308c7dcdf61c8bddd29b19
BLAKE2b-256 3a4a38699f1628ad12b2095315fa216f5dc236c211085ed93bee73f75e0e914e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ed42ce9fcb4a67400a19fa704c1f7a5f17fed0c6f31053e1949f0c82174409bb
MD5 a6a87c5328143b481d90ef4ea85964f1
BLAKE2b-256 2f5ff4881835c231d85b33b31de6f5ae3cfd8addeefb7fd0bafca707406b4265

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 156.5 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.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 726b29df1899fcc47d8cf470a143ef3d7480f7e3a978d80a438ce2e6214c8cd3
MD5 11968e06898a2d8ed9c306753a0afd01
BLAKE2b-256 f5a2c60d73af9aa0fe15e88a50824016b3d8aa30041952c438ac07cf5054278f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eac314e75293f4c21f6fecaa32bc81187f931f51d0e9397404c4c53154b6e98f
MD5 b173c236a6be19fd949f8532dec9e593
BLAKE2b-256 151df2aa4607a4e86f79c494a78f9194cf03ae7c595b4016c03ead5c0c9bb425

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7cf17d0318575698664f31dca047a0e606d5d34f0ee61121560717ac058ef6e0
MD5 cbf16a1d248e74bc89294fcaa1b6ae64
BLAKE2b-256 3217c3eba957c30702a235e60ebea435ee61790fda0ca3e01b0bc58698e240fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oqboost-2.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 155.6 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.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c7fb6f7894ee8be30e0b65e1c33bc7be7a8734703a44afced221dc855e900bc9
MD5 afc14224d03e52fb4ad036df8f77a6ec
BLAKE2b-256 8f517be3cc12b9ce9d55f16bd4c2ef965561e43545538f76612994640fe64d1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f6c46ae6477baf9f82de62c0cd363cd9713d3faa3e053ce47ac69a42e65cb87
MD5 eecbc9f6e005d003650702f0feb5b062
BLAKE2b-256 db762f0ecc837b0b612b87242b5fee32233df0bdc78c35ccb708c794c5a67843

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for oqboost-2.1.0-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7ac8d662be2b55fcf80a3bbd733d96cbc9a5c900b7847dc7bede1d3941a8e298
MD5 f1afd7977b45aadb5c520e86899119e5
BLAKE2b-256 31f9c84e5eb47ed5bd42d5a3b288ef692486a745c461f0ea973bc696c477c699

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