Refresh-aware basis adaptation
Landmarks, anchors, calibration, and fusion refresh only when drift exceeds a threshold — with cooldown, warmup, hysteresis, and an amortized budget.
Kernos is a Python library for refresh-aware hybrid continuous-discrete low-rank kernel learning. Continuous parameters learn by gradient descent. Discrete landmarks refresh only when the basis drifts — so you scale to large-batch and streaming regression without rebuilding the world.
# refresh-aware hybrid kernel regression
import numpy as np
from kernos import Kernos
rng = np.random.default_rng(42)
X_train = rng.standard_normal((4000, 8))
y_train = X_train[:, 0] + 0.5 * X_train[:, 1] ** 2 + 0.1 * rng.standard_normal(4000)
X_test = rng.standard_normal((1000, 8))
model = Kernos(
dim=64, mbasis=256, abasis=32,
ridge=1e-2, steps=500, seed=42,
).fit(X_train, y_train)
print(f"R² on held-out: "
f"{model.score(X_test, y_test):.4f}")
# → R² on held-out: 0.8923 Built on the shoulders of
Every piece of Kernos is engineered for one thing: an adaptive, low-rank kernel that learns continuously and refreshes only when it has to.
Landmarks, anchors, calibration, and fusion refresh only when drift exceeds a threshold — with cooldown, warmup, hysteresis, and an amortized budget.
A familiar `fit` / `predict` / `score` surface. Plays well with `GridSearchCV`, `Pipeline`, and the rest of the sklearn ecosystem.
An explicit-feature kernel with PSD guarantee, a rank bound, and SPD normal equations. Calibration scalars stay bounded away from zero.
Cached `O(nm)` for in-core work and streamed `O(m²)` for large data and online learning — same algorithm, different memory budget.
Anchor sampling weighted by residual magnitude, k-NN sparse RBF features, and orthogonalization that keeps local features in the global nullspace.
Eigenvalue clipping, soft spectral truncation, Cholesky with jitter fallback, and preconditioned conjugate gradient for ill-conditioned solves.
Kernos splits every parameter into a continuously-learned group and a discretely-refreshed group. The expensive refresh fires only when the basis drifts past a threshold you control.
Each step, the continuous parameters learn by gradient descent. Periodically, a drift-aware controller decides whether to refresh the discrete basis — gated by cooldown, warmup, hysteresis, and an amortized refresh budget.
Updated via gradient descent on the validation loss.
Refreshed only when basis drift exceeds a learned threshold.
Project input space into a continuous embedding.
Global Nyström landmarks via k-means++ and spectral whitening.
Residual-aware anchors + orthogonalized local features.
Trace-based calibration + logistic gate across global and local.
Direct, iterative, or Jacobi ridge solve on ΦᵀΦ + λI.
Explicit rank bound: global Nyström landmarks plus local corrective rank.
Constructed as a product of explicit features. Positive semidefinite by construction.
Local features live in the global nullspace, kept stable by ridge regularization.
Kernos was evaluated against Ridge, Nyström, and Random Fourier Features on nine real-world regression datasets. The refresh-aware variant beats the best non-refresh baseline on average — and wins more often than it loses.
Lower rank is better. Across nine datasets, Kernos lands in the top half of eleven models on every one.
kernos-eval --datasets WineQuality --tiers Small --n_seeds 2
kernos-analyze --results results/results.csv
Use Kernos exactly like an sklearn estimator. Tune it with GridSearchCV. Stream it with partial_fit. Drop it into a Pipeline.
import numpy as np
from kernos import Kernos
rng = np.random.default_rng(42)
X_train = rng.standard_normal((4000, 8))
y_train = X_train[:, 0] + 0.5 * X_train[:, 1] ** 2 + 0.1 * rng.standard_normal(4000)
X_test = rng.standard_normal((1000, 8))
model = Kernos(
dim=64, mbasis=256, abasis=32,
ridge=1e-2, steps=500, seed=42,
).fit(X_train, y_train)
print(fclass="hl-s">"R² on held-out: {model.score(X_test, y_test):.4f}")
class=class="hl-s">"hl-c"># → R² on held-out: 0.8923 Kernos ships on PyPI. Python 3.10 or newer, NumPy, SciPy, and scikit-learn — that's it.