Skip to main content

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: t is the moment the prediction is made. Features at anchor t may only use information from ≤ t; targets at anchor t refer 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anchora_simlab-0.1.0.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anchora_simlab-0.1.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

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

Hashes for anchora_simlab-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eaab834c8c611d3fbba5de56b95327d17c5c9e2137aa15d07052066061cc4d6d
MD5 5a7f1a6c0ca79f61d4d64ce8e1cd0e2f
BLAKE2b-256 a7e5c8f7027370af89bcaff7268a626092100ed9d4fe161779e84e1f54cee90f

See more details on using hashes here.

Provenance

The following attestation bundles were made for anchora_simlab-0.1.0.tar.gz:

Publisher: publish.yml on simlab-vs/anchora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for anchora_simlab-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 770ddee9d45eb7c82b82a7890df8be06b946a85b3aa83b0949edb025f1344d7a
MD5 aff521c3ccb17cfa31714641764998d3
BLAKE2b-256 c0ad828a04fa3a32510cd3d16c5a0d4c7d4303c4e42662b9582049169ee612eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for anchora_simlab-0.1.0-py3-none-any.whl:

Publisher: publish.yml on simlab-vs/anchora

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page