A thin, leakage-conscious bridge between polars time-series data and torch/JAX models.
Project description
anchora
A thin, leakage-conscious bridge between polars time-series data and torch/JAX models.
The library owns data semantics — alignment, target construction, splits, the tensor boundary, and getting column names back at the end. You own the model and the training loop entirely. The single invariant everything is organized around:
Every row is an anchor:
tis the moment the prediction is made. Features at anchortmay only use information from≤ t; targets at anchortrefer to information from> t.
Quick tour
from datetime import date
import anchora as ac
# Long-format canonical storage; wide frames are derived views.
frame = ac.TimeFrame.from_wide(df, time="time", freq="1d")
# The only source of date boundaries. Splits are by anchor (prediction) date.
split = ac.TimeSplit(train_end=date(2023, 1, 1), val_end=date(2024, 1, 1))
# Targets are declared compositions of invertible steps.
target = ac.chain(
ac.horizon(5), # y(t+5), aligned to anchor t
ac.delta(baseline="persistence"), # subtract y(t); inverse adds it back
ac.scale("standard"), # fitted strictly on the train part
)
built = target.build(frame, variables=["groundwater_level"], split=split)
# Feature engineering stays free-form polars, contract-checked at the boundary.
@ac.feature_fn
def make_features(wide: pl.DataFrame) -> pl.DataFrame:
return wide.with_columns(pl.col("groundwater_level").shift(3).alias("groundwater lag3"))
features = make_features(frame.wide())
# The tensor boundary: numpy core, thin torch/JAX emitters, identity travels.
m = ac.Matrix(features, built, split, seq_len=30)
for x, y, idx in m.to_torch("train", batch_size=64):
...
# Model output back to a named, raw-space polars frame in one call.
preds = m.wrap_predictions(model_output, part="val")
m.worst(preds, k=5) # ranked worst instances
m.inspect(date(2023, 6, 1)) # lookback window + target for one anchor
Install
uv add anchora # core: polars + numpy
uv add anchora[torch] # torch emitter
uv add anchora[jax] # jax emitter
Documentation and examples
Concept docs live in docs/ (anchor convention, target
chains, the tensor boundary, contracts). Runnable examples with visual checks
live in examples/ — the first three are pure
numpy/polars/matplotlib, the last two add the framework emitters:
uv run examples/01_frame_and_alignment.py # the alignment convention, visually
uv run examples/02_target_chains.py # chain stages + exact round trip
uv run examples/03_linear_model.py # full loop with closed-form ridge
uv run examples/04_torch_lstm.py # LSTM via to_torch (anchora[torch])
uv run examples/05_jax_mlp.py # MLP via to_jax (anchora[jax])
uv run examples/06_forecast_value.py # skill vs pseudo-forecast quality
Design
The founding design spec lives in the JAXifer-harness repository
(docs/superpowers/specs/2026-07-08-anchora-design.md). Deliberately deferred:
the empirical leakage fuzzer (the @feature_fn registry is its replay seam)
and a general fit-window transform protocol (the scale target step is its
prototype).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anchora_simlab-0.1.0.tar.gz.
File metadata
- Download URL: anchora_simlab-0.1.0.tar.gz
- Upload date:
- Size: 37.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaab834c8c611d3fbba5de56b95327d17c5c9e2137aa15d07052066061cc4d6d
|
|
| MD5 |
5a7f1a6c0ca79f61d4d64ce8e1cd0e2f
|
|
| BLAKE2b-256 |
a7e5c8f7027370af89bcaff7268a626092100ed9d4fe161779e84e1f54cee90f
|
Provenance
The following attestation bundles were made for anchora_simlab-0.1.0.tar.gz:
Publisher:
publish.yml on simlab-vs/anchora
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anchora_simlab-0.1.0.tar.gz -
Subject digest:
eaab834c8c611d3fbba5de56b95327d17c5c9e2137aa15d07052066061cc4d6d - Sigstore transparency entry: 2152285071
- Sigstore integration time:
-
Permalink:
simlab-vs/anchora@e62aa3dc0363ac470743cb71e36073a947fbcc63 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/simlab-vs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e62aa3dc0363ac470743cb71e36073a947fbcc63 -
Trigger Event:
push
-
Statement type:
File details
Details for the file anchora_simlab-0.1.0-py3-none-any.whl.
File metadata
- Download URL: anchora_simlab-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
770ddee9d45eb7c82b82a7890df8be06b946a85b3aa83b0949edb025f1344d7a
|
|
| MD5 |
aff521c3ccb17cfa31714641764998d3
|
|
| BLAKE2b-256 |
c0ad828a04fa3a32510cd3d16c5a0d4c7d4303c4e42662b9582049169ee612eb
|
Provenance
The following attestation bundles were made for anchora_simlab-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on simlab-vs/anchora
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anchora_simlab-0.1.0-py3-none-any.whl -
Subject digest:
770ddee9d45eb7c82b82a7890df8be06b946a85b3aa83b0949edb025f1344d7a - Sigstore transparency entry: 2152285105
- Sigstore integration time:
-
Permalink:
simlab-vs/anchora@e62aa3dc0363ac470743cb71e36073a947fbcc63 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/simlab-vs
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e62aa3dc0363ac470743cb71e36073a947fbcc63 -
Trigger Event:
push
-
Statement type: