BlackRubby Regressor
BlackRubby is a numeric regression estimator that fuses two complementary learners:
- Rubby — a symbolic search that evolves closed-form candidate expressions (e.g.
sqrt(x0^3 / (x1 + x2))) on a 3×3×3 cube-walk genome. - Black — a random-Fourier-feature ridge regression that fits a smooth kernel model over the inputs.
The final model is a single ridge over [Fourier features | standardized inputs | symbolic columns], where the bandwidth, ridge strength, and whether to trust the symbolic columns are all chosen by exact leave-one-out cross-validation. It handles multiple numeric input features and one numeric target, with no Python-side dependencies beyond NumPy.
import numpy as np
from blackrubby import BlackRubbyRegressor
rng = np.random.default_rng(7)
X = rng.uniform(-1, 1, size=(512, 3))
y = np.sin(X[:, 0] * X[:, 1]) + 0.2 * X[:, 2]
model = BlackRubbyRegressor(expansion_dim=256, random_state=7)
model.fit(X[:400], y[:400])
print("held-out R2:", model.score(X[400:], y[400:]))
print("champion:", model.champion_formula_)
Install
python -m pip install blackrubby-regressor
Pre-built wheels are published for CPython 3.10–3.13 on Linux (x86_64), Windows (x64), and macOS (Intel and Apple Silicon). On a supported platform this installs in seconds with no compiler.
Building from source requires only a C++17 compiler and CMake. Eigen 3.4.0 is vendored under vendor/eigen, so no network access is needed; set EIGEN3_INCLUDE_DIR to use a different Eigen installation.
How it works
Given training pairs (x_i, y_i) with x_i ∈ R^d, BlackRubby fits a linear model in a lifted feature space:
ŷ(x) = wᵀ Φ(x) + b
The feature map Φ(x) has three blocks:
-
Random Fourier features.
Dcos/sin pairs approximating a stationary kernel:Φ_fourier(x) = (1/√D) [cos(W x̂ / γ), sin(W x̂ / γ)], wherex̂is the standardized input,W ∈ R^{D×d}has standard-normal entries, andγis the bandwidth. This is the classic Rahimi–Recht approximation — asD → ∞, the inner productΦ(x)ᵀΦ(x')converges to the Gaussian kernelk(x, x') = exp(-‖x̂ - x̂'‖² / 2γ²). -
Standardized inputs. The raw
(x - μ) / σblock, which lets the model represent exactly-linear components without spending Fourier capacity on them. -
Symbolic columns (Rubby). Up to
sym_top_kexpressions found by the search, each standardized to zero mean and unit variance. These give the ridge a direct handle on non-smooth or strongly multiplicative structure (ratios, square roots, powers) that Fourier features approximate only slowly.
The ridge weights minimize the regularized squared error:
w* = argmin_w Σ_i (y_i - wᵀΦ(x_i) - b)² + α ‖w‖²
Hyperparameters by exact leave-one-out CV
bandwidth γ, ridge strength α, and the symbolic on/off decision are chosen on a select_rows-row subset using the exact leave-one-out formula for ridge regression. One eigendecomposition of the centered Gram matrix gives the LOO residual for every α in the grid simultaneously:
e_i^LOO = (y_i - ŷ_i) / (1 - h_i), h = U diag(λ_j / (λ_j + nα)) Uᵀ
so the model only leans on the symbolic columns when they demonstrably reduce out-of-sample error. A 2-fold holdout at full feature width re-checks the symbolic decision, because the reduced-width selection screen can mis-rank those columns.
The Rubby symbolic search
Candidate expressions are encoded as a walk on a 3×3×3 cube whose 27 cells each hold one operation or operand (const, x_k, +, -, *, /, log, exp, sqrt, abs, x², x³). Starting from the corner cell, the genome's path (sym_turns moves, each ±x/±y/±z with wraparound) visits cells in order, and the visited nodes form a stack program evaluated column-wise over the data. Each candidate gets a least-squares scale and offset (a·f(x) + b), so the search only has to find the right shape.
A generation consists of tournament selection (with a path-distance diversity check), uniform crossover over cube cells, point mutation, occasional MCTS refinement of the walk itself (UCT over path prefixes), and a periodic Levenberg–Marquardt polish of the constants on the active path. Fitness is normalized mean squared error, NMSE = MSE / Var(y). The best distinct expressions form a hall of fame that feeds the ridge.
The search runs on a strided sym_rows-row subsample for sym_generations generations and is fully seeded by random_state.
Final solve
The full model is solved in primal form over up to solve_rows rows (auto-capped at max(50000, 20 × n_features)), accumulating the centered Gram matrix G = ΦᵀΦ in batches and applying a Cholesky solve with an LDLT fallback.
Reproducibility
With the default sym_time_limit=0, the symbolic search is generation-bounded and fully deterministic: the same random_state, data, and parameters produce a bit-identical model on every run, regardless of thread count or machine load. Setting sym_time_limit > 0 switches to a wall-clock cap, which can stop at different generations on different runs and therefore trades reproducibility for a hard time budget.
API
BlackRubbyRegressor(
expansion_dim=1024, # Fourier cos/sin pairs (D)
alpha=0.0, # ridge strength; 0 = auto by LOO-CV
bandwidth=0.0, # Fourier bandwidth γ; 0 = auto by LOO-CV
random_state=42, # seed for projections and symbolic search
use_symbolic=True, # run the Rubby search
sym_population=128, # GA population size
sym_generations=100, # GA generations (when time limit is 0)
sym_rows=1024, # rows used by the symbolic search
sym_top_k=6, # symbolic columns offered to the ridge
sym_time_limit=0.0, # seconds; 0 = generation-bounded (reproducible)
select_rows=2048, # rows used for hyperparameter selection
select_dim=128, # Fourier pairs used during selection
batch_size=2048, # rows per block in feature assembly
solve_rows=-1, # rows in the final solve; -1 = auto cap, 0 = all
max_frequency=54.598, # largest 1D frequency (standardized units); 1D inputs only
)
Methods: fit(X, y), predict(X), score(X, y) (R²), get_params(), set_params(**params).
After fitting, the following attributes are available:
| Attribute | Meaning |
|---|---|
n_features_in_ |
number of input columns seen during fit |
fit_seconds_ |
total wall-clock fit time |
symbolic_seconds_ |
time spent in the Rubby search |
chosen_bandwidth_ |
selected Fourier bandwidth γ |
chosen_alpha_ |
selected ridge strength α |
uses_symbolic_ |
whether the LOO/holdout checks kept the symbolic columns |
symbolic_columns_ |
number of symbolic columns in the final model |
champion_formula_ |
best expression found, in infix (e.g. 0.9228*exp(x0*x1) - 0.0061) |
Usage notes
Xmust be a finite 1D or 2D numeric array;ymust be one finite numeric target per row. Multi-output regression, categorical encoding, and missing-value imputation are not built in — encode and impute before callingfit.- Fit on training data only, tune on validation data, and report on an untouched test set. The internal LOO-CV protects hyperparameter selection, but it is not a substitute for a held-out evaluation.
- For 1D inputs the Fourier projection is a deterministic log-spaced frequency grid up to
max_frequency, which suits signal-like data; ford ≥ 2the projection is a seeded random Gaussian matrix. score(X, y)returns the coefficient of determination R² (1.0 is perfect, 0.0 is no better than predicting the mean).
Build from source
git clone --recurse-submodules https://github.com/zeusnotjupiter/BlackRubby.git
cd BlackRubby
python -m pip install build
python -m build
(If you cloned without --recurse-submodules, run git submodule update --init first — the Eigen headers under vendor/eigen are required.)
For an editable development build:
python -m pip install scikit-build-core pybind11 cmake numpy
python -m pip install -e . --no-build-isolation
Run the tests with python -m pip install pytest then python -m pytest tests.
Release and publishing
Wheels for all supported platforms are built by the wheels.yml workflow (cibuildwheel) on version tags and can be test-built at any time via manual dispatch. Publishing to PyPI is a separate, explicitly gated step: it requires a PyPI project named blackrubby-regressor, this repository configured as a trusted publisher, and a manual workflow dispatch with publish_to_pypi enabled. No credentials are stored in the repository.
License
Apache License 2.0 — see LICENSE.
Metadata
Release files for blackrubby 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 4.6 MB
Release files / blackrubby-0.1.0-cp313-cp313-win_amd64.whl
| Download URL | blackrubby-0.1.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 545.1 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
84a8f9e92f810390a8070a61db92a5de1dad4d0916dff3e35a0f5f60956e9468
|
|
BLAKE2b-256 checksum How to use checksums |
dff994e282a66a87f7def20a78106a108b9f1540b4a4af53a3ae45bd292f362c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | blackrubby-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 391.8 kB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
a33d7f2efae0b5bf81a49188f3fa9b03783c6d92e27913de5dcf89c00cdcf36c
|
|
BLAKE2b-256 checksum How to use checksums |
6d83514a1ff91bb14b8d779e24bd372beb9cb019ee6110c19e8f7421ba611ac7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | blackrubby-0.1.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 211.7 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f4080b5df1cf9afa6a1bc0c491e958ae7709c046266d18245b4c4426ceedc7d3
|
|
BLAKE2b-256 checksum How to use checksums |
61d8afcc268815f183d9e3407c7cc31a1cc109c971baf88364696de04635bc2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp312-cp312-win_amd64.whl
| Download URL | blackrubby-0.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 545.0 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
33479e26676639fe022abb2a8e70f35271474b7726c1e4a86e46a32b046749a8
|
|
BLAKE2b-256 checksum How to use checksums |
904943c9d2f9cb5ec7bbe9217911c05485774b8be895c92aa14eaa452fc92a69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | blackrubby-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 391.7 kB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
426f2ae1e332c47985374fbe792557e4ee8a4ec5a0ef0bf725876326b343d96c
|
|
BLAKE2b-256 checksum How to use checksums |
bfb25119279c9c37ffd34d7cfe6201e8c4a7498b79b17218d006201bb75023b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | blackrubby-0.1.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 211.7 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
35736773731093c6026dc19ea7dc55fecc3657e6eab760405d98dd12abea4c04
|
|
BLAKE2b-256 checksum How to use checksums |
59270432e243f5fb0592f7fd541303e036c3eb0c9168de5c512424fd0db38362
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp311-cp311-win_amd64.whl
| Download URL | blackrubby-0.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 543.0 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5425c5717bd68325967338ba9d2e87f6deca2b6af849089c9a886dbeb5dcecb2
|
|
BLAKE2b-256 checksum How to use checksums |
cd5b44dd31d8b7bf0aa53ab267e8872ae835fa267cd9479701c75e85a984c5c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | blackrubby-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 389.1 kB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
0fac62d9c716711218e3303840518ace81e9c6127e09e9a3f0765b90762aa09c
|
|
BLAKE2b-256 checksum How to use checksums |
9af2ef88168decce635175a529db80e43b36fdd8c5fd61498c27ae13b56922b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | blackrubby-0.1.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 210.5 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4d3406edc629f0369914e952e0761a46ed3f5e7bb02915087295b6ba7fb1ca1c
|
|
BLAKE2b-256 checksum How to use checksums |
ffe547bdcf619eeb2be17068924d28b33f9910d1388e11037f1a0acaf299b234
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp310-cp310-win_amd64.whl
| Download URL | blackrubby-0.1.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 542.1 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4e244487e6b0ebc266142a28974f83d27e0bf7d7f7de556f5b7681eb2113dd81
|
|
BLAKE2b-256 checksum How to use checksums |
ec796bc72b5fbc80481354bb27b3d631fec65761ee959352cb4e26aa40d69fe8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | blackrubby-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 383.3 kB |
| Tags | CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
95a59f797eb0dd3d1972245377210cde23628f3886ddf5cfdb461d6447ec49c9
|
|
BLAKE2b-256 checksum How to use checksums |
6001824ca5158e73c8087d5cd49bc3d2c2f1199f2fb5ebe3a72ca57f4ec1502c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logRelease files / blackrubby-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | blackrubby-0.1.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 209.1 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
11186fb0c15137f971b70a4facccc6dd9f674491b047081c831e680a48682c52
|
|
BLAKE2b-256 checksum How to use checksums |
d2f676be93dec4bd3eab6ff3e9a1d0d0644fd94ea5095cc62cf2912af3ad24ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logSecurity for blackrubby 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.
Full provenance
All 12 files in this release have been uploaded with provenance metadata.
Attestation for blackrubby-0.1.0-cp313-cp313-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.
Transparency logA 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.