Skip to main content

py-gboost

Python bindings for the gboost gradient-boosting library.

It exposes a single GradientBooster class backed by the Rust core, with a sklearn-like fit(x, y) / predict(x) API over NumPy float32 arrays. All training work (histogram binning, split search, per-batch update) runs in Rust; fit and fit_next release the GIL while the booster grows.

Installation

py-gboost is a maturin package; it builds the Rust extension and installs it as the importable module gboostrs.

# From a release build
pip install .

# Or, for in-place development
pip install maturin
maturin develop

Requires Python 3.9+. The import name is gboostrs:

import gboostrs
gboostrs.__version__

Quick start

import numpy as np
from gboostrs import GradientBooster

rng = np.random.default_rng(1)
x = rng.standard_normal((100, 5)).astype(np.float32)  # (rows, cols)
y = rng.standard_normal(100).astype(np.float32)        # one value per row

# Regression
gb = GradientBooster(objective="squaredloss", iterations=100)
gb.fit(x, y)
scores = gb.predict(x)      # np.ndarray of float32, one score per row
gb.loss()                   # mean loss of the current predictions vs. the labels

# Binary classification (labels in {0, 1})
y = rng.integers(0, 2, 100).astype(np.float32)
gb = GradientBooster(objective="logloss", iterations=100)
gb.fit(x, y)

Growing round by round

fit(x, y) trains up to iterations rounds and replaces any previously trained model. fit_next() grows one additional round on the existing model and returns False when a round produced no tree (no gain) — the natural early-stopping signal.

gb = GradientBooster(objective="squaredloss", iterations=0)
gb.fit(x, y)                # fit(0) builds the booster without growing trees

while gb.fit_next():
    print(gb.loss())

GradientBooster

All parameters are keyword-only and have defaults, so GradientBooster() is a valid, fully-configured instance.

Parameter Default Description
iterations 100 Maximum boosting rounds run by fit.
objective "squaredloss" Loss to minimize: "squaredloss" (regression) or "logloss" (classification).
base_score 0.0 Initial constant prediction before any tree is added.
max_bins 255 Maximum number of quantization bins per column.
persist_path None Directory for on-disk artifacts, if persistence is used.
parallel True Enable the parallel (Rayon) execution paths.
seed 0 Seed for reproducible random draws (subsampling).
learning_rate 0.3 Per-tree update step size.
subsample 1.0 Row subsampling fraction per tree.
colsample_bytree 1.0 Per-tree feature subsampling fraction.
colsample_bylevel 1.0 Per-level feature subsampling fraction.
colsample_bynode 1.0 Per-node feature subsampling fraction.
max_depth 6 Maximum tree depth (0 = no limit).
max_leaves 0 Maximum number of leaves (0 = no limit).
grow_policy "depthwise" Tree growth policy: "depthwise" or "lossguide".
reg_alpha 0.0 L1 regularizer on leaf weights.
reg_lambda 1.0 L2 regularizer on leaf weights.
min_split_gain 0.0 Minimum gain required to take a split.
min_child_weight 1.0 Minimum hessian sum allowed in a leaf.
allow_missing_splits False Whether missing values may drive their own split.
onehot_columns [] Indices of columns to treat as one-hot categoricals (exact-bin splits).

Methods

  • fit(x, y) -> None — Train the booster. x is a 2-D float32 matrix of shape (rows, cols); y is a 1-D float32 target of length rows. Replaces any previously trained model.
  • fit_next() -> bool — Grow one additional round on the trained model. Returns False when the round produced no tree (no gain).
  • predict(x) -> np.ndarray — Score x (shape (rows, cols), same column count as training) with the trained model; returns one float32 score per row.
  • loss() -> float | None — Mean loss of the current predictions against the training labels, or None before fit.
  • get_params() -> dict — Return the constructor kwargs as a dict of name -> value; GradientBooster(**gb.get_params()) reconstructs an equivalent instance.

Notes

  • Zero-copy inputs. The Rust core works on column-major (Fortran-order) arrays. Pass x as np.asfortranarray(x) to avoid a copy; row-major or strided inputs are transposed into column-major internally.
  • Error types. I/O failures (e.g. an invalid persist_path) raise IOError; other problems (an untrained model, a NaN in the target, a column-count mismatch in predict, an invalid objective/grow_policy) raise ValueError.
  • onehot_columns. Columns listed here are split on an exact bin (==) rather than an ordered threshold (<=), so high-cardinality categoricals are first-class. Other columns are treated as linear (ordered) features.
  • Determinism. With a fixed seed and subsample, a run is reproducible.

Tests

The test suite exercises the binding end-to-end (regression, classification, fit_next, and error paths):

pip install pytest
pytest tests/

Metadata

Release files for gboostrs 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gboostrs 0.1.0
File Size Uploaded Provenance Actions
gboostrs-0.1.0.tar.gz 69.3 kB Without provenance Details for gboostrs-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for gboostrs 0.1.0
File Actions
gboostrs-0.1.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for gboostrs-0.1.0-cp313-cp313-win_amd64.whl
gboostrs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details for gboostrs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
gboostrs-0.1.0-cp313-cp313-manylinux_2_34_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ ARM64 Details for gboostrs-0.1.0-cp313-cp313-manylinux_2_34_aarch64.whl
gboostrs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for gboostrs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
gboostrs-0.1.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for gboostrs-0.1.0-cp312-cp312-win_amd64.whl
gboostrs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details for gboostrs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
gboostrs-0.1.0-cp312-cp312-manylinux_2_34_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ ARM64 Details for gboostrs-0.1.0-cp312-cp312-manylinux_2_34_aarch64.whl
gboostrs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for gboostrs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
gboostrs-0.1.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for gboostrs-0.1.0-cp311-cp311-win_amd64.whl
gboostrs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ x86-64 Details for gboostrs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
gboostrs-0.1.0-cp311-cp311-manylinux_2_34_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.34+ ARM64 Details for gboostrs-0.1.0-cp311-cp311-manylinux_2_34_aarch64.whl
gboostrs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details for gboostrs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl

Total release size: 6.8 MB

Release files / gboostrs-0.1.0.tar.gz

Download URL gboostrs-0.1.0.tar.gz
Size 69.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c12350846c11ef1f383efaf8e28a974c327dd67d5921d7fadd6aa50bf462a92e
BLAKE2b-256 checksum
How to use checksums
958618f0265b23516358a9e8825f57aea37241368b1956379bd8c19a40486d0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp313-cp313-win_amd64.whl

Download URL gboostrs-0.1.0-cp313-cp313-win_amd64.whl
Size 440.4 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
b006dca5f5e8585379e1c80a728b12b8b323d86d555c104df709073a41369158
BLAKE2b-256 checksum
How to use checksums
8e7404643e9436c9fb315a5679f2bebf58b9aefc867b6b146c0a478562c61d28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL gboostrs-0.1.0-cp313-cp313-manylinux_2_34_x86_64.whl
Size 630.1 kB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
d6675008e71f450ec55a29a393047b40e73565c71811922ba41941f8d473986b
BLAKE2b-256 checksum
How to use checksums
0a9858d999555ecb97ff9b78c2e672503423bfadc6308d7511791f6ac8ba1699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp313-cp313-manylinux_2_34_aarch64.whl

Download URL gboostrs-0.1.0-cp313-cp313-manylinux_2_34_aarch64.whl
Size 627.3 kB
Tags CPython 3.13 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
dc02c85e00f06a22bbbfb5edf2ae4284e570363b4f2f95e0c14e6301473d898c
BLAKE2b-256 checksum
How to use checksums
a997973afb55e20e00fae16efa5ccfaab698d9ef8c5a4b7fe42f99b9b0947e1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL gboostrs-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Size 553.3 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dd298261b4853e9f2fead617c42e3bc92744dc240d3f2fb5504c918bae83692b
BLAKE2b-256 checksum
How to use checksums
98714ab1839c431f522266bf373ff0d7343ba7f1a7cd547d0318ddcec395a49b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp312-cp312-win_amd64.whl

Download URL gboostrs-0.1.0-cp312-cp312-win_amd64.whl
Size 440.9 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
7894c78263b6952da0b93f1f0e05145a6ea1e12a10fcb88cc8603e84cc6b02a5
BLAKE2b-256 checksum
How to use checksums
1bf09344d3499f907cb8df7c99909f5f11acb1972a0fb41098b48c776a6b16d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL gboostrs-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Size 630.3 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
bd5d550810c13307d7e333b76e8ae0b132192639c4ea365c0418e0254744c24d
BLAKE2b-256 checksum
How to use checksums
be8786794ebbdf507948b1cfbfa4b816d0fb4de92bbb0c609982c56850c59179
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp312-cp312-manylinux_2_34_aarch64.whl

Download URL gboostrs-0.1.0-cp312-cp312-manylinux_2_34_aarch64.whl
Size 626.2 kB
Tags CPython 3.12 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
a29696ecec4dae214ef6c79a5028c640c652fd224846eceb1eb26a8535d0df50
BLAKE2b-256 checksum
How to use checksums
bbbb34916c7c7ae19bede468586d6c391d473e07dffa08cab2424e673cca7ed4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL gboostrs-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Size 553.4 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4879bad55d2296511ee0e9ea32784e6f210f696cfc244128f82159503ed28945
BLAKE2b-256 checksum
How to use checksums
d9b948e672b2bc70282f5d938eadd867e2c6ee6f1ed7b889f16434dd8f284f39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp311-cp311-win_amd64.whl

Download URL gboostrs-0.1.0-cp311-cp311-win_amd64.whl
Size 444.3 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
e2f9750a69109d69d9d96d8130d577688bc66e618c5c02b8d931e343e8d30af1
BLAKE2b-256 checksum
How to use checksums
10688094ceb36ec320b2de07304d298a43cd6cd97b3ed3c2f27a327ae7f482b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl

Download URL gboostrs-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Size 633.3 kB
Tags CPython 3.11 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
44fef70fe0dfa95ea7f5c9b00806329362643e7af033388407fd39e4a8fa59e8
BLAKE2b-256 checksum
How to use checksums
e5aa81ea65ef0dc358bb5523fd004d8462649f3f1b534ba3027d6305d6758b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp311-cp311-manylinux_2_34_aarch64.whl

Download URL gboostrs-0.1.0-cp311-cp311-manylinux_2_34_aarch64.whl
Size 630.4 kB
Tags CPython 3.11 Linux glibc 2.34+ ARM64
SHA-256 checksum
How to use checksums
0269b5fe451f066bd85f1c15ad7e84c7750d58de4e207e0bb0ef2cc5cd1b8417
BLAKE2b-256 checksum
How to use checksums
1ea553d392550663d27890177befadb1e41476508c4cd1df2c4d7ed22134ac6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / gboostrs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL gboostrs-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Size 557.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
dd1ca31a7053316bfdd275bf68d68d00d6481d941191789d855f4890ab9047cf
BLAKE2b-256 checksum
How to use checksums
23a956f77ba941ec4aab6d54719569a3608825f14ebac9f4c338d17596d7fcb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for gboostrs 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

13 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page