Skip to content

Python API

Generated from the docstrings in src/renewable_huber. The normative contract, including every constructor parameter, fitted attribute and state field, is API and state contract; where the two differ, that page wins.

RenewableHuberRegressor

RenewableHuberRegressor(
    *,
    tau: float = 1.345,
    penalty: Penalty = "none",
    lambda_scale: float = 1.0,
    bandwidth_scale: float = 1.0,
    fit_intercept: bool = True,
    max_iter: int = 100,
    tol: float = 1e-06,
    ridge: float = 1e-08,
    backend: BackendName = "auto",
    device: DeviceName = "auto",
    dtype: DTypeName = "float64",
    n_jobs: int | None = None,
    cuda_graphs: bool = False,
    cuda_fast_math: bool = False,
)

Robust linear regression that can be updated one batch at a time.

Parameters mirror :class:~renewable_huber.config.EstimatorConfig. The estimator executes on NumPy, CuPy/CUDA, PyTorch, or TensorFlow tensors on CPU/CUDA. TensorFlow is supported in its default eager-execution mode.

Notes

fit resets the state and processes its input as one batch. Use partial_fit repeatedly for a genuine streaming workflow. The retained state contains coefficients and an accumulated information matrix, never historical raw observations.

state_ property

state_: RenewableHuberState

Return a defensive copy of the renewable sufficient state.

diagnostics_ property

diagnostics_: UpdateDiagnostics

Diagnostics generated by the most recently processed batch.

get_params

get_params(deep: bool = True) -> dict[str, object]

Return constructor parameters, compatible with scikit-learn cloning.

set_params

set_params(**params: object) -> RenewableHuberRegressor

Set constructor parameters and invalidate any fitted state.

reset

Discard fitted state so a new stream can begin.

fit

fit(
    X: ArrayLike,
    y: ArrayLike,
    sample_weight: ArrayLike | None = None,
) -> RenewableHuberRegressor

Reset the estimator and fit a single initial batch.

partial_fit

partial_fit(
    X: ArrayLike,
    y: ArrayLike,
    sample_weight: ArrayLike | None = None,
) -> RenewableHuberRegressor

Consume one batch while retaining only renewable summary state.

sample_weight uses frequency-weight semantics: zero-weight rows are ignored numerically, and integer weights are equivalent to repeating rows. At least one row in every submitted batch must have positive weight.

predict

predict(X: ArrayLike) -> Any

Predict with the current streamed estimator state.

score

score(
    X: ArrayLike,
    y: ArrayLike,
    sample_weight: ArrayLike | None = None,
) -> float

Return the ordinary coefficient of determination (R²).

state_dict

state_dict() -> dict[str, object]

Return portable model data for custom checkpointing integrations.

save

save(path: str | Path) -> Path

Save configuration and sufficient state as a safe .npz checkpoint.

load classmethod

load(
    path: str | Path,
    *,
    backend: BackendName | None = None,
    device: DeviceName | None = None,
    dtype: DTypeName | None = None,
) -> RenewableHuberRegressor

Restore a model, optionally migrating its state to another backend.

SklearnRenewableHuberRegressor

SklearnRenewableHuberRegressor(
    *,
    tau: float = 1.345,
    penalty: Penalty = "none",
    lambda_scale: float = 1.0,
    bandwidth_scale: float = 1.0,
    fit_intercept: bool = True,
    max_iter: int = 100,
    tol: float = 1e-06,
    ridge: float = 1e-08,
    backend: BackendName = "auto",
    device: DeviceName = "auto",
    dtype: DTypeName = "float64",
    n_jobs: int | None = None,
    cuda_graphs: bool = False,
    cuda_fast_math: bool = False,
)

Bases: RegressorMixin, RenewableHuberRegressor, BaseEstimator

Use renewable Huber regression in scikit-learn meta-estimators.

The numerical API is inherited unchanged. The adapter adds scikit-learn's regressor tags and base-estimator behaviour so that clone, Pipeline, GridSearchCV, and cross-validation treat it as a regressor.

fit

fit(X, y, sample_weight=None)

Fit after applying scikit-learn's one-dimensional target contract.

partial_fit

partial_fit(X, y, sample_weight=None)

Update after applying scikit-learn's target-shape contract.

predict

predict(X)

Predict after applying scikit-learn's fitted-state contract.

Exceptions

Package-specific exceptions.

RenewableHuberError

Bases: Exception

Base exception for renewable_huber.

NotFittedError

Bases: RenewableHuberError

Raised when an operation requires a fitted estimator.

BackendUnavailableError

Bases: RenewableHuberError

Raised when a requested numerical backend is unavailable.

ValidationError

Bases: RenewableHuberError, ValueError

Raised when an input or configuration violates the public contract.

BackendContractError

Bases: RenewableHuberError, TypeError

Raised when input violates a backend's own transport contract.

It inherits :class:TypeError, so every existing handler keeps working, while being a distinct type lets the estimator tell "this array cannot be coerced to a number" apart from "this backend refuses this array, and here is exactly why". Only the first deserves the scikit-learn-compatible coercion message; the second already says something more useful and must reach the caller intact rather than being rewritten.