v0.2.0 — refresh-aware kernel learning·release notes →

Adaptive kernels,
refreshed when they drift.

Train a low-rank kernel regressor on large batches or streaming data without rebuilding its basis at every update. Kernos keeps learning continuously and refreshes landmarks only when they drift.Under the hood: refresh-aware hybrid continuous-discrete kernel learning, exposed through a familiar scikit-learn-style API.

scikit-learn-style interface
PSD kernel guarantee
Streaming & cached modes
MIT licensed
quickstart.py
import numpy as np
from kernos import Kernos

rng = np.random.default_rng(42)
X_train = rng.standard_normal((80, 4))
y_train = X_train[:, 0] + 0.5 * X_train[:, 1] ** 2 + 0.1 * rng.standard_normal(80)
X_test = rng.standard_normal((20, 4))
y_test = X_test[:, 0] + 0.5 * X_test[:, 1] ** 2 + 0.1 * rng.standard_normal(20)

model = Kernos(
    dim=4,
    mbasis=16,
    abasis=4,
    lk=4,
    ridge=1e-2,
    steps=1,
    seed=42,
).fit(X_train, y_train)

print(f"R² on held-out: {model.score(X_test, y_test):.4f}")
# The score depends on the dataset, seed and training budget.

Built on the shoulders of

NumPySciPyscikit-learnHuggingFacePyPIpytest
Capabilities

Kernel learning, without the rebuild.

Every piece of Kernos is engineered for one thing: an adaptive, low-rank kernel that learns continuously and refreshes only when it has to.

Refresh-aware basis adaptation

Landmarks, anchors, calibration, and fusion refresh only when drift exceeds a threshold — with cooldown, warmup, hysteresis, and an amortized budget.

Scikit-learn-style interface

A familiar `fit` / `predict` / `score` surface that integrates with `GridSearchCV` and `Pipeline` when the configured basis and validation capacity fit the dataset.

Mathematical guarantees

An explicit-feature kernel with PSD guarantee, a rank bound, and SPD normal equations. Calibration scalars stay bounded away from zero.

Two memory modes

Cached `O(nm)` for in-core work and streamed `O(m²)` for large data and online learning — same algorithm, different memory budget.

Residual-aware local corrections

Anchor sampling weighted by residual magnitude, k-NN sparse RBF features, and orthogonalization that keeps local features in the global nullspace.

Numerically stabilized

Eigenvalue clipping, soft spectral truncation, Cholesky with jitter fallback, and preconditioned conjugate gradient for ill-conditioned solves.

System map

Two parameter groups, one disciplined loop.

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.

The hybrid loop

Continuous descent. Discrete refresh.

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.

∂
Continuous θ, Revery step

Updated via gradient descent on the validation loss.

Δ
Discrete Z, A, M_g, c_g, c_l, ρon drift

Refreshed only when basis drift exceeds a learned threshold.

Drift
frobenius · spectral
Trigger
d_t > drift_hi
Cooldown
cool = 50
Budget
amortized
Pipeline

Five stages. One coherent model.

  1. 01
    EmbedΦ

    Project input space into a continuous embedding.

  2. 02
    BasisZ, M_g

    Global Nyström landmarks via k-means++ and spectral whitening.

  3. 03
    CorrectA, M_l

    Residual-aware anchors + orthogonalized local features.

  4. 04
    Fusec_g, c_l, ρ

    Trace-based calibration + logistic gate across global and local.

  5. 05
    Solvew

    Direct, iterative, or Jacobi ridge solve on ΦᵀΦ + λI.

rank(K) ≤
r_g + m_l

Explicit rank bound: global Nyström landmarks plus local corrective rank.

kernel PSD
K = ΦΦᵀ

Constructed as a product of explicit features. Positive semidefinite by construction.

orthogonality
Φ_gᵀ Φ_l ≈ 0

Local features live in the global nullspace, kept stable by ridge regularization.

Evidence

Measured against the best of the rest.

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.

Datasets evaluated
9
real-world · Small tier
Mean ΔRMSE vs best baseline
−7.99
% improvement · mean across 9 datasets
Win rate vs Nyström
8 / 9
datasets · 5 CPU seeds
Win rate vs RFF
8 / 9
datasets · 5 CPU seeds

Summary scope: Small budget tier, five controlled CPU seeds, mean RMSE across the evaluated datasets. Results are descriptive; hardware and dataset changes can alter the outcome.

Pareto plots — RMSE vs train time

RMSE and training time, shown together.

KernosBaselines
Pareto plot for WineQuality
WineQualityRMSE ↓ vs time
Pareto plot for California Housing
California HousingRMSE ↓ vs time
Pareto plot for YearPredictionMSD
YearPredictionMSDRMSE ↓ vs time
Pareto plot for Kin8nm
Kin8nmRMSE ↓ vs time
Ablation impact

Refresh is a measured trade-off, not a universal win.

Ablation impact for WineQuality

On this recorded sweep, disabling refresh improves RMSE for some datasets. Treat refresh as a controllable adaptation mechanism and validate it against your workload rather than assuming it always improves accuracy.

Per-dataset ranking

A transparent per-dataset view.

  • Abalone
    #6 / 11
  • CPUActivity
    #2 / 11
  • CaliforniaHousing
    #3 / 11
  • Elevators
    #5 / 11
  • HouseSales
    #3 / 11
  • Kin8nm
    #4 / 11
  • Superconduct
    #3 / 11
  • WineQuality
    #3 / 11
  • YearPredictionMSD
    #3 / 11

Lower rank is better. Across nine datasets, Kernos lands in the top half of eleven models on every one.

Reproduce locally:kernos-eval --datasets WineQuality --tiers Small --n_seeds 2kernos-analyze --results results/results.csv

How to read these results

Full evaluation protocol →

Splits: 70 / 15 / 15 train, validation and test, scaled on train only.

Stability: five controlled CPU seeds; tables report mean ± standard deviation.

Budgets: Small, Medium and Large tiers vary basis size and training horizon.

Metrics: RMSE, train time, peak Python allocation, refresh count and condition proxy. Native RSS is not measured in this table.

These headline aggregates are descriptive, not a guarantee for every dataset or hardware configuration. Re-run the pinned protocol before drawing a performance conclusion.

API

Familiar surface.
Sophisticated internals.

Use Kernos through a familiar scikit-learn-style estimator API. Tune it withGridSearchCV. Stream it with partial_fit. Drop it into a Pipeline.

  • kernos.Kernos — the estimator class.
  • kernos.Buffer — FULL or STREAM memory modes.
  • kernos-eval — CLI for the full evaluation suite.
  • kernos-analyze — produce plots, CSVs, LaTeX tables.
import numpy as np
from kernos import Kernos

rng = np.random.default_rng(42)
X_train = rng.standard_normal((80, 4))
y_train = X_train[:, 0] + 0.5 * X_train[:, 1] ** 2 + 0.1 * rng.standard_normal(80)
X_test = rng.standard_normal((20, 4))
y_test = X_test[:, 0] + 0.5 * X_test[:, 1] ** 2 + 0.1 * rng.standard_normal(20)

model = Kernos(
    dim=4,
    mbasis=16,
    abasis=4,
    lk=4,
    ridge=1e-2,
    steps=1,
    seed=42,
).fit(X_train, y_train)

print(f"R² on held-out: {model.score(X_test, y_test):.4f}")
# The score depends on the dataset, seed and training budget.
Get started

Install with one command.

Kernos ships on PyPI. Python 3.10 or newer, NumPy, SciPy, and scikit-learn — that's it.

  • pip install kernos — production install.
  • pip install -e ".[dev,examples]" — for evaluation suite and plots.
  • MIT licensed — commercial and academic use.
bash
$ pip install kernos
Successfully installed kernos-0.2.0
$ python -c "import kernos; print(kernos.__version__)"
0.2.0
$ kernos-eval --datasets WineQuality --tiers Small
→ results/pareto_WineQuality.png
CI matrix: Python 3.10–3.14
Verify locally on your target platform