FeatureLedger
Automatically retained fitted preprocessing, exact training influences, ordered input schemas, trusted artifact restoration and native regression.
ImplementedAner 0.1.0 or newerFeatureLedger is the native fitted preprocessing artifact returned by ml.fit_standardizer for an AdaptiveFrame. It retains the ordered input feature schema, population statistics and exact training dependencies automatically. Import aner.ml; users do not need to construct a separate history container before fitting a model.
Building energy regression supplies a complete checked program. Training temperatures [10, 20] produce center 15 and population scale 5, so the held out temperature 100 transforms to 17. Fitting that statistic on held out rows must fail with a located R3501 diagnostic containing E_FIT_SCOPE.
Return to the model and technique reference for the complete family index.
Place this workflow in aner.ml
Return to the aner.ml module guide for the other fitted model families. For this contextual family, construct a typed table and declared frame through aner.data, separate authorized populations, fit preprocessing on training, transform each population with the same fitted artifact, pack a contextual batch and fit/predict. The building energy tutorial is the full step by step reference; this page is the API/contract lookup.
Run the complete local example
The complete energy source uses the distributed energy CSV and standardization CSV, with no network, credentials or GPU. From the folder containing examples:
aner check examples/contextual_energy.aner
aner run examples/contextual_energy.anerRun in a writable folder with those relative fixtures present. The program creates new energy.scaler.anermodel and energy.linear.anermodel files; move or rename earlier outputs before repeating because save refuses overwrite. It prints 8 training, 4 validation and 4 test rows; two input features; first validation row ID 401; target unit kWh; and true checks for both held out errors below 1e-9 and the first prediction within 1e-9 of 108 kWh. The separate scaling fixture prints exact 15.0, 5.0, 17.0, then restoration verifies the anchored prediction contract with true. These are synthetic rule checks, rather than performance claims on external data.
Fitting and transformation
ml.fit_standardizer(training) requires an authorized training frame. It learns population standard deviation (ddof = 0) from numerical feature columns; identity, group and target columns are excluded. A constant feature uses scale 1. Missing or nonfinite required input values fail rather than being imputed.
ml.transform(preprocessing, observations) returns a new frame. Its numerical features are standardized and its original feature units remain described in the fitted input schema. The target remains in its declared original unit. Training, validation and test roles are preserved; processing a held out frame does not authorize fitting on it.
Learned dependencies survive registered selection, rename, numerical packing and model operations. Fitting a new artifact checks both the current rows and the fitted influences of its inputs. Exploratory full data preprocessing cannot acquire strict training authorization by partitioning its output afterward. An artifact from another experiment or fold cannot be silently reused in an incompatible scope.
Applied preprocessing contract
The ordered preprocessing applied to values is a separate contract from the observations that influenced fitting. Matching field IDs, dimensionless units or valid training scope alone does not prove that a numeric batch has been prepared correctly. The runtime retains at most 64 applied stages, each identified by a stable fingerprint of its fitted inputs, ordered feature meaning and parameters.
A standardizer records its exact expected input chain. Transformation must match that chain before appending the fitted stage; applying the same artifact to its own output fails with a located R3501 diagnostic containing E_FEATURE_SCHEMA. A second standardizer fitted after the first requires the first stage at inference as well. Prediction validates the exact chain used during training and rejects raw, extra or differently ordered preprocessing before producing output.
Persistence fingerprints use semantic field descriptors rather than serialized native IDs. Restoration recomputes against the live trusted anchor and rebinds the verified stages to its local scope. Equivalent legitimately reconstructed anchored pipelines match; file contents do not authorize themselves. This bounded ordered processing contract is not a general replayable feature DAG.
Model boundary and prediction identity
The first complete estimator is native CPU Float64 linear regression with an intercept and checked least squares QR. Linear fitting requires a nonmissing target for every training row; unlabeled inference keeps that training rule intact. It rejects deficient rank; no hidden regularization or fallback is selected. Its input schema comes from the contextual batch. Prediction validates the ordered schema and preserves observation IDs and target unit. Independent unlabeled observations require explicit mapping and unit alignment; matching names do not grant training membership. Evaluation also checks the prediction/target observation domain, rather than accepting equal shapes alone.
Numeric scalar readout is useful for inspection but is not a tracked model input constructor. Source declarations, unrelated manually reconstructed values and operations outside the registered runtime cannot prove experimental validity automatically. This system validates explicit supported contracts; it does not infer concealed target proxies or control choices made after examining results elsewhere.
Persistence and trust
Supported fitted artifacts use bounded versioned native files with integrity verification. Saving creates a new file and refuses to overwrite an existing artifact. Loading requires a live trusted training anchor; file names, hashes, text IDs and serialized process pointers cannot independently grant a fit scope. Learned parameters and exact dependencies are checked against that anchor.
A checksum verifies the serialized payload's integrity, not that a scientific measurement or declared split is correct. Unsupported foreign restoration must not create a trusted training history from detached numerical values.
Native API signatures
Qualified functions and the corresponding recognized receiver methods use the same native contracts. self denotes the receiver in the qualified signature. Lists of names or units contain Strings; index lists contain Int64 values. Wrong List element types fail instead of coercing values.
| Native signature | Result |
|---|---|
ml.row_ids(self: ContextPrediction) | List |
ml.row_id(self: ContextPrediction, index: Int64) | Int64 |
ml.summary(self: FeatureLedger) | String |
ml.explain(self: FeatureLedger) | String |
ml.summary(self: ContextLinearModel) | String |
ml.explain(self: ContextLinearModel) | String |
ml.summary(self: ContextPrediction) | String |
ml.explain(self: ContextPrediction) | String |
ml.fit_standardizer(training: AdaptiveFrame) | FeatureLedger |
ml.fit_exploratory_standardizer(data: AdaptiveFrame) | FeatureLedger |
ml.transform(self: FeatureLedger, data: AdaptiveFrame) | AdaptiveFrame |
ml.align_inputs(self: FeatureLedger, observations: AdaptiveFrame, columns: List) | AdaptiveFrame |
ml.align_inputs(self: ContextLinearModel, observations: AdaptiveFrame, columns: List) | AdaptiveFrame |
ml.center(self: FeatureLedger) | Tensor |
ml.scale(self: FeatureLedger) | Tensor |
ml.fit_linear(training: ContextBatch) | ContextLinearModel |
ml.predict(self: ContextLinearModel, samples: ContextBatch) | ContextPrediction |
ml.rmse(self: ContextPrediction, targets: ContextBatch) | Float64 |
ml.values(self: ContextPrediction) | SemanticTensor |
ml.unit(self: ContextPrediction) | String |
ml.load_standardizer(path: String, training_anchor: AdaptiveFrame) | FeatureLedger |
ml.load_linear(path: String, training_anchor: ContextBatch) | ContextLinearModel |
ml.save(self: FeatureLedger, path: String) | Unit |
ml.save(self: ContextLinearModel, path: String) | Unit |
Parameter, shape and error details
center() and scale() return detached CPU Float64 1 × P tensors in the ledger's fitted numerical feature order; scales are positive and constant features use 1. summary() is a readable bounded overview and explain() describes retained schema/dependencies. Prediction row_ids() returns a List of Int64 IDs in prediction order; row_id(index) is zero based. values() returns a SemanticTensor of shape N × 1 retaining aligned observation identity and the target unit. rmse(targets) requires matching observation domain, target meaning and contextual preparation, then returns error in the original target unit.
The exploratory standardizer accepts an unspecified frame but does not authorize its influences for a later strict training fit. Required inputs are finite and present; no missing value imputation, automatic feature alignment or regularization is selected. Wrong schemas/applied-stage order use R3501 with E_FEATURE_SCHEMA; unauthorized influences use E_FIT_SCOPE; mismatched prediction domains use their located contextual diagnostic. A deficient rank QR fit fails explicitly. Artifact loading also verifies the trusted training anchor and payload integrity; save requires an existing parent directory and a new output path. There are no optional fitting parameters or hidden estimator defaults in these signatures.
Every input and fixed model choice
The signatures above have no optional fitting hyperparameters. The following table explains the variables that select observations, feature preparation, inference alignment and persistence. The receiver name self denotes an existing fitted artifact or prediction, rather than a newly fitted model.
| Parameter | Required value and constraint | Meaning and effect |
|---|---|---|
training in ml.fit_standardizer | Authorized AdaptiveFrame with finite, present numerical feature values. | Chooses the population used to learn each feature's mean and population scale. Target, ID and group columns are not fitted feature columns. |
data in ml.fit_exploratory_standardizer | Unspecified AdaptiveFrame. | Declares exploratory fitting; it does not grant a strict training scope to the resulting influences. |
self in ledger operations | A fitted FeatureLedger. | Chooses exactly the learned schema, statistics and expected applied stage chain to transform or inspect. |
data in ml.transform | Schema and chain compatible AdaptiveFrame. | Supplies values to transform without refitting. Current observation role and identity remain attached. |
observations in ml.align_inputs | Independent observations as an AdaptiveFrame, compatible with the fitted schema after explicit mapping/conversion. | Aligns external feature meaning while retaining its external row root; it does not turn those observations into authorized fitting rows. |
columns in ml.align_inputs | List of Strings, one source column for each fitted feature in fitted order. | Makes feature mapping explicit. Wrong count, type, missing/duplicate mappings or incompatible units fail rather than guessing. |
training in ml.fit_linear | Labeled, authorized ContextBatch; at least P+1 rows for P features and a full rank intercept augmented feature matrix. | Selects the inputs and target for the CPU Float64 intercept least squares fit. A missing target or rank deficient system fails explicitly. |
self in linear model operations | A fitted ContextLinearModel. | Selects the learned coefficients, exact fitted feature order, required preparation and target meaning. |
samples in ml.predict | Compatible ContextBatch; observed targets are optional for inference. | Supplies observations to predict without updating coefficients or preprocessing. |
targets in ml.rmse | Labeled ContextBatch aligned to the prediction's observation domain and target meaning/unit. | Supplies evaluation truth. Equal dimensions alone are insufficient. |
self in prediction readouts | A ContextPrediction. | Selects values, row identities, target unit, summary or dependency explanation. |
index in ml.row_id | Zero based Int64 within the prediction row count. | Reads the original Int64 observation ID at that position; it is not itself a source row ID. |
path in save/load | String naming a bounded supported artifact; saving requires a new path with an existing parent. | Saving preserves parameters/dependencies; loading verifies payload integrity and its relationship to the live anchor. |
training_anchor | Authorized AdaptiveFrame for load_standardizer, or labeled ContextBatch for load_linear. | Recomputes the supported fit and binds verified saved meaning to the live trusted experiment scope. A matching filename or shape cannot replace this anchor. |
The standardizer always uses population variance (ddof = 0) and a constant column scale of 1. The linear model always includes an intercept and uses two pass QR; there is no exposed fit_intercept, regularization strength, learning rate, epoch count, solver selection, optimizer or random seed. A partition or data generation operation can have its own seed, but neither of these fitting functions consumes one. The fixed singularity guard rejects a residual column norm at most 1e-12 times its original norm, or a zero norm; it does not regularize the fit. These fixed choices are part of the model contract, not omitted configuration options.
Time and space complexity
Let n be training rows, p numerical features, h retained dependency descriptors and H the exact influence membership examined during fit validation. Up to 64 learned influences are retained.
| Operation | Time | Additional space |
|---|---|---|
| Fit population standardization | O(np + n log n + H) | Retained O(p + h); peak additional O(np + n + p + h) including packed fit values and exact membership checks |
| Transform a frame | Expected O(np + h) | O(np + Np + h) standardized output and root row lookup buffers, where N is source rows |
| Inspect center/scale | O(p) | O(p) numerical readout |
| Fit intercept least squares | O(np² + n log n + H) | O(np + p² + n + h) checked solver workspace and retained artifact |
Predict n observations | O(np + h) | O(n + h) prediction and identity outputs |
| Aligned RMSE | O(n + h) | O(1) reduction state after retained context validation |
Schema, population and transitive dependency validation add their actual descriptor traversal cost; the ledger is not traversed for each numeric multiply. Artifact IO and payload integrity verification are linear in serialized bytes, capped at 1 MiB. Loading also recomputes the standardizer or QR fit against the trusted anchor and therefore adds its fit time and peak workspace. Source rows are bounded to 1,000,000, fields to 64, numerical matrices to 1,000,000 cells and checked managed numerical buffers to 64 MiB.
Dependencies, backends and limitations
Use Aner 0.0.5 runtime with aner.data, aner.ml, and VS Code helper 0.1.38 or newer. The reference workflow is CPU Float64 and needs no network, GPU or external database. Contextual batches accept optional observed targets; target readout, fitting and RMSE reject unlabeled batches. Same root held out prediction preserves its existing exact feature and experiment checks. Independent observations use the explicit inference alignment adapter. An empty frame target declares unlabeled inputs; align against the first fitted ledger, apply the exact fitted stages, then predict. Alignment preserves the external row root and grants no fitting permission. The building energy tutorial remains the held out workflow; the separate unlabeled inference example exercises independent observations.
The new linear estimator resolves the current CLI or nn.configure execution profile at fit, predict and model restoration. Only effective CPU Float64 is supported. A conflicting Float32 or GPU profile fails with a located R3501 diagnostic containing E_BACKEND_UNSUPPORTED; it does not silently run a different backend. The normal preserve policy can resolve a requested Metal/MPS Float64 execution to a reported CPU Float64 fallback. CSV/statistics preparation retains its documented CPU behavior.
The supported standardizer and linear estimator are a narrow complete path, not a general feature store or experiment registry implementation.
General feature DAGs, supervised target encoders, historical feature availability, arbitrary estimators, streaming partial fitting and contextual distributed training remain future work. Existing independent training and parallel modules retain their own documented contracts.