Skip to main content

Model-agnostic symbolic-regression data layer: Problem, versioned ProblemCatalog, and ProblemSource (curated sets / on-the-fly generation / fixed).

Project description

symbolic_data

The model-agnostic symbolic-regression data layer, carved out of flash-ansr: skeleton/expression sampling, priors, (X, y) support sampling, holdout management, and dataset construction.

Both symbolic-regression methods (for training holdout) and the srbf eval framework depend on it, so training, holdout, and evaluation draw from one source of truth. Its only heavy dependency is simplipy; otherwise just numpy/sklearn plus huggingface_hub (for resolving versioned catalogs from the HF asset repo).

Install

pip install symbolic-data

Quick start

import symbolic_data

# 1. Load a curated catalog (level 1: expressions + their intrinsic per-variable sampling). The
#    curated sets are Hugging Face artifacts (not bundled in the wheel): a bare `name` needs network
#    on first use, then caches; pass an explicit local path for offline use. `load_catalog("name@version")`
#    resolves a versioned catalog from the HF manifest, and `load_catalog("user/repo:name")` loads a
#    third party's published catalog.
feynman = symbolic_data.load_catalog("feynman")            # 100 equations (Udrescu & Tegmark 2020)
entry = feynman["I.6.2a"]
entry.prepared, entry.variables                            # expression + intrinsic per-variable sampling

# 2. Draw (X, y) Problems from a ProblemSource (level 2). Mode is inferred from the config:
#    a declarative/frozen `catalog` ref (set), a generative `catalog` ref (generate, on-the-fly),
#    or inline `problems` (fixed).
src = symbolic_data.ProblemSource({"catalog": "feynman",
                                   "sampling": {"n_support": 32, "n_validation": 32, "noise": 0.01}})
for problem in src:
    if problem.is_placeholder:                                                        # a slot the source could not fill (recorded, not skipped)
        continue
    problem.x_support, problem.y_support, problem.y_support_noisy, problem.expression  # fit / tokenize

# 3. Freeze for exact reproduction (no seeds): materialize() -> a fixed source that re-iterates
#    byte-identical Problems, identical across models/runs.
frozen = src.materialize()

Extensibility

Distributions are pluggable via a registry: in-process with @symbolic_data.DISTRIBUTIONS.register("name"), or across packages via an importlib.metadata entry point in the symbolic_data.distributions group. A registered name drops into the same {"name": ..., "kwargs": ...} config slot as a builtin (e.g. the fastsrb distribution).

Catalogs are extensible through the resolver: publish your own to a Hugging Face dataset repo with a manifest.json, then symbolic_data.load_catalog("your-user/your-repo:name@version").

Versioning / reproducibility

Reproducibility comes from fixed data, not seeds: sampling draws from a threaded numpy.random.Generator (entropy by default), and exact reproduction across runs/models is obtained from a fixed (materialized) catalog rather than by re-seeding. Versioned catalogs resolve from Hugging Face with a pinned revision and a sha256 integrity check. Catalogs are HF artifacts (not bundled in the wheel since 0.8.0): a bare name needs network on first use, then caches; pass an explicit local path for fully offline operation.

Status: 0.10.0. The full public stack: Problem, the unified distribution framework (incl. the fastsrb distribution), and the Catalog a ProblemSource samples from -- either a declarative ProblemCatalog (+ load_catalog + the versioned HF resolver) or an on-the-fly GenerativeCatalog (LampleChartonCatalog: random unary-binary operator trees; build_catalog dispatches a catalog: {type: ...} config). ProblemSource adds the usage policy (draw method, support/validation counts, noise, holdouts/filters, problems_per_expression, unbounded streaming, materialize() + to_catalog() for frozen, byte-reproducible catalogs). Generate-mode is fully Generator-driven (no global np.random). The skeleton/support/holdout machinery stays private (_generate); the public face is LampleChartonCatalog. Curated catalogs (FastSRB, Feynman, Nguyen) are published to the HF assets repo and resolved by name (not bundled in the wheel). CLI: symbolic-data materialize. 0.10.0 breaking: LampleChartonCatalog.load(directory) now returns the catalog object only (was (config_dict, catalog)), consistent with ProblemCatalog.load; read the config separately via load_config(<dir>/catalog.yaml) if you need it (see the CHANGELOG). Deferred: a frozen holdout grid; functional-equivalence exclude (currently exact normalized-expression match).

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

symbolic_data-0.10.0.tar.gz (72.0 kB view details)

Uploaded Source

Built Distribution

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

symbolic_data-0.10.0-py3-none-any.whl (62.9 kB view details)

Uploaded Python 3

File details

Details for the file symbolic_data-0.10.0.tar.gz.

File metadata

  • Download URL: symbolic_data-0.10.0.tar.gz
  • Upload date:
  • Size: 72.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for symbolic_data-0.10.0.tar.gz
Algorithm Hash digest
SHA256 217ad857713bc5dcfc8592ea30938aaddaf6f6cf560284899b78210c5a8e99f8
MD5 6d786e331bcb403fcd88e3039c4ab961
BLAKE2b-256 0e4ccd12f4df8e7679712b2ecb8c904284c8226bcf90673ac32d55756ac98a90

See more details on using hashes here.

Provenance

The following attestation bundles were made for symbolic_data-0.10.0.tar.gz:

Publisher: publish.yaml on psaegert/symbolic-data

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

File details

Details for the file symbolic_data-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: symbolic_data-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 62.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for symbolic_data-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f41c125992b0f211882dd5b14110d7b8c910ded71a473fd7c94f568378978959
MD5 8ef7e6f39ceb10f3dcb78eca8c8380c7
BLAKE2b-256 0cf07f91c20a35f401ff9473a5c4ce99ef9da1da46ea32654b4e48b6c75e5ac7

See more details on using hashes here.

Provenance

The following attestation bundles were made for symbolic_data-0.10.0-py3-none-any.whl:

Publisher: publish.yaml on psaegert/symbolic-data

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