Fitted Ridge regression
Fit a regularized continuous target model with training only scaling, unit aware predictions, and held out error.
ImplementedAner 0.1.0 or newerAner 0.0.8 adds a fitted Ridge workflow for a continuous target in an AdaptiveFrame. A model plan fits optional standardization and regression together. Predictions retain observation IDs and the fitted target's unit. Evaluation accepts labeled validation or test rows from the fitted experiment and returns RMSE in the target unit.
From the source root, run the building energy example.
aner check examples/ridge_energy.aner
aner run examples/ridge_energy.anerAfter declaring the group populations, fitting and evaluation take two calls.
let model = ml.ridge(alpha: 0.1).fit(parts.train())
print(model.evaluate(parts.test()))| Operation | Behavior |
|---|---|
ml.ridge(alpha: 1.0, standardize: true) | Returns an immutable RidgePlan. Either named option may be supplied on its own. |
plan.fit(training, max_bytes: 67108864) | Fits an immutable FittedRidge on an authorized training view. |
plan.cross_validate(training, folds: 5, seed: 42) | Returns a List of fold RMSE values. Each fold fits preprocessing again, using only its own training rows. |
model.predict(observations) | Returns ContextPrediction. Use row_id(index), unit(), or values() to inspect it. |
model.evaluate(held_out) | Returns Float64 RMSE for a labeled, nonempty validation or test view in the fitted experiment. |
model.align_inputs(observations, columns) | Explicitly maps independent unlabeled observations to the fitted input fields in order, including compatible unit conversions. |
model.coefficients(), model.intercept() | Describe the model in its fitted coordinates. Coefficients follow feature order. |
model.center(), model.scale() | Return training means and population standard deviations. Constant features use scale one. When scaling is disabled, centers are zero and scales are one. |
model.save(path), ml.load_ridge(path, training_anchor[, max_bytes]) | Save to a new path and reload by verifying a refit on the matching live training view. The artifact includes the fitted coefficients and scaling. |
plan.summary(), model.summary() | Describe the objective, effective settings, and fitted model. |
The objective is the sum of squared residuals plus alpha times the sum
of squared feature coefficients. The intercept is always fitted and is
unpenalized. Alpha must be finite and strictly positive. If standardization
is enabled, the penalty applies in standardized coordinates. The fit learns
these statistics from training rows only. Missing feature or target values
are rejected. Training rejects held out views. Independent alignment
authorizes prediction only.
Cross validation uses only the outer training view. Supply two to 32 folds
and at least as many declared groups. Whole groups stay together. The seed
breaks ties between groups of equal size, and larger groups go to the fold
with the fewest rows so far. Fold results follow that assignment order.
Preprocessed inputs are rejected because their fitted statistics could
already include a fold's validation rows. Folds run sequentially, and
max_bytes applies to each fit and evaluation. Fold assignment and scope
metadata are separate from that numerical budget.
Ridge runs on CPU Float64. A bound feature reader reads rows from the existing table or its spill storage without constructing a full training tensor. Givens QR uses O(p²) numerical workspace for p features. On Accelerate builds, sufficiently tall problems can use Householder QR on blocks of up to 256 rows if the budget permits. Both paths use O(n p²) work for n rows. Fitted membership and prediction outputs also scale with row count. The byte budget covers the managed numerical payload and fitted membership. The existing table, frame selection, provider internals, and allocator overhead are outside this budget. AdaptiveFrame size limits still apply.
A saved artifact retains fitted state and a deterministic signature. Restore it with the corresponding authorized training view from a live experiment. Reload recomputes and verifies the fit with the saved solver, so it costs a fit and requires a compatible solver and numerical environment. The live training view supplies the fit and evaluation permissions.
See the Machine learning module reference for the shared API.