Skip to main content

nirs4all-datasets

nirs4all-datasets

A citable, reproducible bank of raw NIRS (Near-Infrared Spectroscopy) reference datasets — for benchmarking, exploring, and comparing models on a common, version-pinned, provenance-rich footing.

Part of the open-source NIRS tools ecosystem: file readers, datasets, methods, browser modelling, reproducible pipelines, papers, benchmarks, and release dashboards for near-infrared spectroscopy.

A dataset here is raw measured reality, not a benchmark task: one or more spectral sources (instruments), any number of variables (every target and metadata column — nothing is invented, and nothing is thrown away), the native splits if the source defined them, and full provenance back to the origin that published the data. The task — which Y, which split, which metric — is a choice the consumer makes; it is never baked into the dataset.

This repository is split into one native acquisition layer and optional consumer-facing layers:

  1. a git-tracked catalog — one hand-checkable descriptor + a machine-generated identity card (stats, per-source/per-variable dataviz, MLCommons Croissant, a Datasheet) per dataset. The heavy bytes never enter git.
  2. a native acquisition core — Rust crates + stable n4ds_ C ABI + CLI/bindings that resolve dataset ids, fetch canonical bytes from their origin, verify SHA-256, and manage the platform cache. This surface does not require Python.
  3. an optional Python package/binding — nirs4all-datasets embeds that acquisition core for get()/retrieve()/NirsDataset, plus the catalog, cards, and site tooling.
  4. optional ecosystem bridges — the [nirs4all] extra for modelling/qualification and the [io] extra for raw-origin reproduction through nirs4all-io / nirs4all-formats.

It reuses nirs4all only through the optional [nirs4all] bridge for qualification and to_nirs4all(), and nirs4all-io / nirs4all-formats only through the optional [io] bridge for raw-origin reproduction. It never re-implements NIRS/IO logic.

Status: 0.3.x, pre-1.0 — the on-disk and API contracts may still change.

The dataset model

  • Sources (X) — 1..n, kept separate. Multi-instrument / multi-block datasets keep each block as its own source. Sources may even carry different numbers of spectra (asymmetric repetitions): they are aligned by sample identity (sample_id), never by row position.
  • Variables (Y + metadata) — 0..n. There is no intrinsic Y/metadata distinction: every column is a potential target. A dataset may declare no target at all (X-only / metadata-only is valid). Declared targets are flagged; everything else is kept as metadata, with full per-variable dataviz either way.
  • Splits — documented, never auto-applied. Native train/test/fold partitions are recorded so you can reproduce a paper's split, but get() never silently applies one.
  • Tiers — how a dataset is shown and exported. public (everything shown, openly fetchable from the origin), private (everything shown; export needs a token), anonymized (variable names masked + targets normalized; export needs a token). Bytes are never served from git or the site — the catalog points at the origin DOI/URL; a personal Dataverse is only a future fallback for protected datasets.
  • Versions — two axes. A content version (bumps when the dataset bytes change) and a metric-protocol version (lets the cards be re-qualified under a new protocol without rebuilding the data).

Install (development)

uv venv && uv pip install -e ".[dev]"   # builds the optional Python package + embedded native core
# (uses local editable sibling bridges via [tool.uv.sources]; needs a Rust toolchain)

Native acquisition core, bindings, and optional bridges

The download/acquisition path of a dataset — version-pinned DOI resolution, redirect-safe Dataverse / Zenodo / figshare fetch, streaming SHA-256 verification, and platform-cache management — lives in a small Rust core (crates/nirs4all-datasets-core) behind a stable C ABI (n4ds_). The scientific analysis layer (cards, qualify, site, health) stays in Python. The cross-language contract is one distributable catalog/index.json; n4ds resolve returns both the byte contract and the tier-sanitized schema-2.0 descriptor (sources, variables, ids, splits, retrieval). The n4ds CLI is the parity oracle. Surfaces over that core:

Binding Package Status
Python optional nirs4all-datasets package, embedding nirs4all_datasets._n4ds (pyo3) built + tested
Rust nirs4all-datasets-core / -capi (crates.io) built + tested
WASM/JS @nirs4all/datasets-wasm (npm) — metadata + small public datasets built + tested
R nirs4alldatasets (C shim, r-universe / Release) built + tested
Octave/MATLAB MEX (GitHub Release zip) built + tested

See bindings/SPEC.md (the binding contract) and docs/dev/release_process.md.

The Python package uses its bundled catalog and original-source loading recipes. For non-Python consumers, the native acquisition core consumes the bundled or committed catalog/index.json contract directly. R/WASM/Rust clients resolve the index and fetch listed resources with host-native tooling. The dataset-specific Python assembly recipes are marked as delegate routes in that contract.

Quickstart

import nirs4all_datasets as n4ad

n4ad.list()                              # the catalog index
n4ad.card("perten_cereals_nir")        # generated card if present locally (otherwise None)

ds = n4ad.get("perten_cereals_nir")    # -> NirsDataset (original resources fetched, assembled, cached)
ds.sources()                             # ['X'] for this dataset
ds.x("X")                               # one source's spectra as a 2D numpy array
ds.x(concat=False)                       # {source_id: array} for every source (sample-aligned, not row-aligned)
ds.y()                                   # all declared targets, per sample
ds.metadata()                            # the metadata columns (each a potential target)
ds.split("original")                     # the native split labels, if the source defined one
ds.to_nirs4all()                         # hand off to nirs4all for modelling

The installed package includes the 242-entry catalog and origin-loading recipes for 95 reproducible public-origin recipes. Run from any directory; no checkout or CIRAD source bundle is needed. The malaria database requires an explicit optional guestbook profile. See public-origin loading for the profile option, provider limits, and the native ChEMBL peak-list representation.

Private / anonymized datasets need a Dataverse token: n4ad.get("name", token=...).

CLI (n4a-datasets)

bootstrap <tree>                 author schema-2.0 descriptors from <tree>/v2.0/*  (--prune to re-base)
build-all --source-tree <tree>   organize + qualify every dataset in parallel  (--protocol-refresh, --site)
add <raw_source> <id>            one raw source -> canonical + card + index
qualify <id>                     (re)build a dataset's card  (--anonymize -> card.anon.json)
health-check                     probe each dataset's open origins -> catalog/health.json
catalog | list | card | get      regenerate the index / inspect / load a dataset
publish | grant | revoke | restrict   personal-Dataverse governance for protected data (future)

n4a-datasets <command> --help documents every flag.

What lives where (3-tier storage)

  • git (small, tracked): catalog/datasets/<id>.yaml (descriptor), catalog/datasets.yaml (index + whole-bank summary), and per-dataset card.json / card.md / croissant.json / manifest.json.
  • the origin (Zenodo, a data Dataverse, a vendor archive, …): the raw + canonical bytes, fetched on demand and never re-hosted by this project.
  • local cache (downloaded on demand): the verified canonical Parquet under the native acquisition core's platform cache root.

API token — where to put it

A Dataverse API token is only needed to fetch private/anonymized datasets or to publish to a personal Dataverse; public datasets need none. Resolution order:

  1. Environment variable NIRS4ALL_DATAVERSE_TOKEN (recommended; required in CI).
  2. ~/.config/nirs4all-datasets/config.toml (chmod 600):
    [dataverse]
    instance = "https://entrepot.recherche.data.gouv.fr"
    token = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    
  3. A project .env (gitignored) — see .env.example.

The token travels only in the X-Dataverse-key header, is never logged, and is never sent on a redirect to signed object storage. Never commit it (.env, config.toml, *.token are gitignored).

Contributing

Full walkthrough in CONTRIBUTING.md; the design is in docs/DESIGN.md. The green gate (run before every commit) mirrors CI:

ruff check . && mypy --config-file pyproject.toml src
python catalog/scripts/validate.py            # every descriptor is schema-valid
pytest -q

License

Code is dual-licensed open-source — CeCILL-2.1 OR AGPL-3.0-or-later (your choice) — with an optional commercial license for closed-source / SaaS use; for any commercial use, contact nirs4all-admin@cirad.fr. See LICENSING.md, LICENSES/ and THIRD_PARTY_NOTICES.md.

Catalog content (cards, datasheets, metadata) is licensed CC-BY-4.0. Each dataset carries its own SPDX license in its descriptor and is only ever linked to its origin — open data is never re-hosted under a different license.

Metadata

Release files for nirs4all-datasets 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nirs4all-datasets 0.4.0
File Size Uploaded Provenance Actions
nirs4all_datasets-0.4.0.tar.gz 4.1 MB With provenance Details for nirs4all_datasets-0.4.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for nirs4all-datasets 0.4.0
File Interpreter ABI Platform Actions
nirs4all_datasets-0.4.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for nirs4all_datasets-0.4.0-cp311-abi3-win_amd64.whl
nirs4all_datasets-0.4.0-cp311-abi3-manylinux_2_34_x86_64.whl CPython 3.11 abi3 Linux glibc 2.34+ x86-64 Details for nirs4all_datasets-0.4.0-cp311-abi3-manylinux_2_34_x86_64.whl
nirs4all_datasets-0.4.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for nirs4all_datasets-0.4.0-cp311-abi3-macosx_11_0_arm64.whl

Total release size: 27.2 MB

Release files / nirs4all_datasets-0.4.0.tar.gz

Download URL nirs4all_datasets-0.4.0.tar.gz
Size 4.1 MB
Tags Source
SHA-256 checksum
How to use checksums
671dae7768f59e68cce0ad00f476596f696750dfa3593c831415305397b80bc2
BLAKE2b-256 checksum
How to use checksums
7fb185bf78d0f9d1ea632220dd8be5706ebb4e2d615e62aac61f539204bfc4be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / nirs4all_datasets-0.4.0-cp311-abi3-win_amd64.whl

Download URL nirs4all_datasets-0.4.0-cp311-abi3-win_amd64.whl
Size 7.3 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3a9c23a0cb02c3c08c088f9d9f3784f60f73c411cb3be20e321024e6cb8cf66c
BLAKE2b-256 checksum
How to use checksums
0bf719c2703a875c3b377f7dc647dc52b74e5c8d1fb874906c56e5c169dd1e9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / nirs4all_datasets-0.4.0-cp311-abi3-manylinux_2_34_x86_64.whl

Download URL nirs4all_datasets-0.4.0-cp311-abi3-manylinux_2_34_x86_64.whl
Size 8.6 MB
Tags CPython 3.11 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
a9f6e56216c9ce31e7924bc5ba18e0ca1f46c04077ce8b92f6589dac09fe8ec6
BLAKE2b-256 checksum
How to use checksums
cb58caf6115c89d51cfef7cdc8ced7b0d31902f6fb99cfa3603642ca6ae605e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / nirs4all_datasets-0.4.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL nirs4all_datasets-0.4.0-cp311-abi3-macosx_11_0_arm64.whl
Size 7.2 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7e08a11afc64fc93b7c05b150dac85bc629a7f1d2457c7d143bb198a2b691e12
BLAKE2b-256 checksum
How to use checksums
86fe4bc4f6df9d37c69d0ef919cdf0ea5e2a99d370492a4b6bc5ccb7770a6811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for nirs4all-datasets 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for nirs4all_datasets-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

4 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page