Skip to content

renewable-huber

CI PyPI Python versions License: Apache-2.0

renewable-huber is a Renewable Huber Regression package for streaming data. It implements robust linear regression based on the Huber loss, and while processing batches it retains only the coefficients and an accumulated information matrix, never every historical observation.

The latest version is 0.7.1, published on PyPI, but the package is still in pre-alpha development. It provides RHE and L1-penalised RPSHE updates on NumPy/CPU, Rust/Rayon native CPU, CuPy/CUDA, Rust/CUDA native, PyTorch and TensorFlow (CPU/CUDA), resumable .npz checkpoints, and integration with pandas and scikit-learn Pipeline/model-selection tools. Run renewable-huber --version to see the installed version.

python -m pip install renewable-huber
import numpy as np
from renewable_huber import RenewableHuberRegressor

model = RenewableHuberRegressor(penalty="l1", lambda_scale=0.5)

for X_batch, y_batch in data_stream:
    model.partial_fit(X_batch, y_batch)

print(model.coef_, model.intercept_)
prediction = model.predict(X_test)
model.save("checkpoints/model.npz")

restored = RenewableHuberRegressor.load("checkpoints/model.npz")
assert np.allclose(prediction, restored.predict(X_test))

data_stream, X_test and the other names above are placeholders for your own batches: any iterable of (X_batch, y_batch) pairs of NumPy arrays or pandas objects works.

Where to go next

  • Installation: the base package, the optional Rust CPU and CUDA engines, and the extras for pandas, scikit-learn, CuPy, PyTorch and TensorFlow.
  • Quick start: streaming updates, pandas and scikit-learn input, sample weights and what streaming means for reproducibility.
  • Backends: how backend="auto" chooses, and how to run on the Rust CPU engine, CuPy, the native CUDA engine, PyTorch or TensorFlow.
  • Checkpoints: saving, restoring and migrating a stream between backends and dtypes.
  • Reference: the public API and state contract, the support matrix and the generated Python API.
  • Development: contributing, architecture, the release process and the native-core design notes.

Languages

The user guide and this page are in English. The API contract, support matrix, architecture, release documents and maintainability report are written in Traditional Chinese and are marked (中文) in the navigation. A Traditional Chinese README, which is also the PyPI project description, is on GitHub.

Research source and licence

This project is an independent software implementation of the method in the original Renewable Huber paper (Electronic Journal of Statistics, DOI). It is not an official package created, sponsored, approved or endorsed by the paper's authors or their institutions. The research article is licensed under CC BY 4.0; this project's source code is licensed under the Apache License 2.0, and detailed attribution notices are in NOTICE.