Skip to main content

pls4all

pls4all is the slim, PLS-only subset of nirs4all-methods — a thin Python binding over the portable libn4m C ABI (a C++17 PLS / NIRS engine). The wheel bundles the libn4m shared library, so pip install pls4all is self-contained; no separate native build is required. For the full method surface (preprocessing, selectors, diagnostics, augmenters, …) install the nirs4all-methods package instead and import it as n4m — both load the same libn4m.

The binding loads libn4m with ctypes.CDLL (so the GIL is released during native calls) and exposes:

  • version() / abi_version() introspection,
  • a Pythonic Context and Config (RAII lifecycle wrappers),
  • the PLS fit/predict surface and a scikit-learn-compatible pls4all.sklearn.PLSRegression (and the other PLS-family estimators),
  • a typed Pls4allError raised on any non-OK status, carrying the context's last_error message.

Quick start

import numpy as np
import pls4all
from pls4all.sklearn import PLSRegression

print(pls4all.version())      # e.g. "1.0.10+abi.2.3.0"
print(pls4all.abi_version())  # (2, 3, 0)

rng = np.random.default_rng(0)
X = rng.standard_normal((40, 12))
y = X @ rng.standard_normal(12)

model = PLSRegression(n_components=5).fit(X, y)
print(model.predict(X).shape)  # (40,)

Low-level lifecycle, if you need it:

with pls4all.Context() as ctx, pls4all.Config() as cfg:
    cfg.algorithm = pls4all.Algorithm.PLS_REGRESSION
    cfg.solver = pls4all.Solver.SIMPLS
    cfg.n_components = 5
    # ... drive a fit through the C ABI ...

scikit-learn is an optional dependency (only pls4all.sklearn needs it); the core import pls4all works with NumPy alone.

Pure-native estimator selection in the full package

The full nirs4all-methods distribution (imported as n4m) exposes the native single-level finetuning driver. It is not part of the slim pls4all namespace. Build the validation plan and search space through public owning objects:

import numpy as np

from n4m.model_selection import (
    Algorithm,
    Metric,
    Sampler,
    SearchSpace,
    ValidationPlan,
    finetune_estimator,
)

rng = np.random.default_rng(42)
X = rng.normal(size=(60, 12))
y = X @ rng.normal(size=12) + rng.normal(scale=0.02, size=60)
fold_ids = np.arange(X.shape[0], dtype=np.int32) % 5

with ValidationPlan.from_fold_ids(fold_ids) as plan:
    with SearchSpace() as space:
        space.add_int("n_components", 1, 10)
        result = finetune_estimator(
            Algorithm.PLS_REGRESSION,
            X,
            y,
            plan,
            space,
            n_trials=30,
            sampler=Sampler.TPE,
            metric=Metric.RMSE,
            seed=42,
            timeout_seconds=20.0,
        )

print(result.best_params)       # for example: {"n_components": 6}
print(result.best_score)
print(result.timed_out)         # True only for a successful partial timeout
print(len(result.trials))       # owning completed/failed trial snapshots

The eligible algorithms are PLS_REGRESSION, PLS_CANONICAL, PLS_SVD, OPLS, SPARSE_PLS and PCR. The five non-sparse routes require the exact keyword n_components, a non-log integer axis. SPARSE_PLS accepts any non-empty subset of n_components and sparsity_lambda; omitted axes retain the native defaults 2 and 0.0. sparsity_lambda must stay in [0, 1) and may be declared with space.add_float(..., log=True) when low > 0.

This call selects a configuration and returns an owning trace; it does not fit a final estimator on all rows. A timeout before any completion raises N4MError with CANCELLED. A later timeout returns the best partial result with result.timed_out is True and fewer trials than result.requested_trials. See docs/methods/optimization.md for the exact schema, status and validation-plan contracts.

Relation to nirs4all conformal learning and robustness

The Python bindings are thin translation layers over the libn4m C ABI. They expose native kernels, scikit-learn-compatible PLS estimators and the single-estimator finetune_estimator(...) selection trace, but they do not own the higher-level nirs4all statistical lifecycle.

Use nirs4all.run(tuning=...) when the workflow needs final winner projection, workspace persistence, .n4a packaging, optional nirs4all.calibrate() / predict_calibrated() semantics, CalibratedRunResult, or nirs4all.robustness() / RobustnessReport artifacts. Those guarantees and invalidation reasons are produced by nirs4all, not by n4m or pls4all.

Binding consumers must not reimplement tuning/conformal/robustness guarantees from raw native predictions. A UI, Studio panel or alternate language binding that wants to display conformal intervals or robustness summaries should consume the public nirs4all artifact/schema surfaces instead of inferring guarantees locally from finetune_estimator(...) or PLSRegression.predict(...).

Loading libn4m

The bundled wheel ships libn4m inside pls4all/lib/, found automatically. For development against a local build the loader searches, in order:

  1. $PLS4ALL_LIB_PATH — explicit path to libn4m for this package,
  2. $N4M_LIB_PATH — shared libn4m override honoured by both pls4all and n4m,
  3. pls4all/lib/libn4m* next to the installed package (wheel layout),
  4. <repo-root>/build/dev-release/cpp/src/libn4m* (developer convenience),
  5. the standard system search path (LD_LIBRARY_PATH, macOS rpath, Windows PATH).

Building libn4m from source (developers)

cmake --preset dev-release
cmake --build --preset dev-release --parallel

This produces build/dev-release/cpp/src/libn4m.so (.dylib / .dll on macOS / Windows), which the loader rules above pick up.

See https://github.com/GBeurier/nirs4all-methods for the full project.

Download files

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

Source Distribution

pls4all-1.0.11.tar.gz (143.8 kB view details)

Uploaded Source

Built Distributions

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

pls4all-1.0.11-py3-none-win_amd64.whl (1.4 MB view details)

Uploaded Python 3Windows x86-64

pls4all-1.0.11-py3-none-musllinux_1_2_x86_64.whl (5.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

pls4all-1.0.11-py3-none-musllinux_1_2_aarch64.whl (4.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

pls4all-1.0.11-py3-none-manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

pls4all-1.0.11-py3-none-manylinux_2_28_aarch64.whl (4.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

pls4all-1.0.11-py3-none-macosx_11_0_universal2.whl (7.9 MB view details)

Uploaded Python 3macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file pls4all-1.0.11.tar.gz.

File metadata

  • Download URL: pls4all-1.0.11.tar.gz
  • Upload date:
  • Size: 143.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pls4all-1.0.11.tar.gz
Algorithm Hash digest
SHA256 75a3f43727927be7ea844b1115057eed36cb03d3a52a1d12a967be75ff2eda16
MD5 07faf16d6374aa2bee3b4e01080da6cc
BLAKE2b-256 ed655a4714873e73c9c28cb97ad14d96f3a8ab06f15bf503278dc5146ecdf765

See more details on using hashes here.

Provenance

The following attestation bundles were made for pls4all-1.0.11.tar.gz:

Publisher: release-python.yml on GBeurier/nirs4all-methods

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

File details

Details for the file pls4all-1.0.11-py3-none-win_amd64.whl.

File metadata

  • Download URL: pls4all-1.0.11-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pls4all-1.0.11-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a6035a4bb352c34eab0615a38f6dce0e8642e8c6d8b73015523df9b52259e673
MD5 c4a82e080c52d3dd685df637afd4b224
BLAKE2b-256 c7f6abf57d7b9637b394cdd42f98d55d5f3da5a052dc0f97362a8ec30e5a734d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pls4all-1.0.11-py3-none-win_amd64.whl:

Publisher: release-python.yml on GBeurier/nirs4all-methods

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

File details

Details for the file pls4all-1.0.11-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pls4all-1.0.11-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 442f0791f7cd729da231d698f3536b2fc1ca55d2ae2fcb01c443a0058679d295
MD5 4b1d9873986e9f851b1541dc56e73d9a
BLAKE2b-256 25094d911377da542391d98bf07b9f797cb9967b02194cdf4ce20bf293f09358

See more details on using hashes here.

Provenance

The following attestation bundles were made for pls4all-1.0.11-py3-none-musllinux_1_2_x86_64.whl:

Publisher: release-python.yml on GBeurier/nirs4all-methods

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

File details

Details for the file pls4all-1.0.11-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pls4all-1.0.11-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 16f6fd6aff9660b5b6e7d30af0a837a3d34495c31f6e367d1d371eef6f61ee09
MD5 092de02b2bf9e76fef69637e242eba97
BLAKE2b-256 8f45a53e52cf2874d35fdc85e94498c89e971af31ea91c43c4062288f54a7518

See more details on using hashes here.

Provenance

The following attestation bundles were made for pls4all-1.0.11-py3-none-musllinux_1_2_aarch64.whl:

Publisher: release-python.yml on GBeurier/nirs4all-methods

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

File details

Details for the file pls4all-1.0.11-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pls4all-1.0.11-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7abea9dc61db6dec415a08ef62de280c72728f4d6e35187eaf110ea3e507a125
MD5 341c55858c41fb03fbe56003e4828fe9
BLAKE2b-256 51bd7060a73cbef6433c0460df0615dd2f5f802874dec24d3e3b9e913c4c5e78

See more details on using hashes here.

Provenance

The following attestation bundles were made for pls4all-1.0.11-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release-python.yml on GBeurier/nirs4all-methods

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

File details

Details for the file pls4all-1.0.11-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pls4all-1.0.11-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 203f43e63653b6953145885a2d7ed4fb0a0e3c46739a5c37ecc32265cc9cc50c
MD5 8fc568a0901a5723779dbad961528dbd
BLAKE2b-256 d3ae481de529cc9776cb8283823b1e12927cd0855e75aa9a6f4fd2d83e339c19

See more details on using hashes here.

Provenance

The following attestation bundles were made for pls4all-1.0.11-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release-python.yml on GBeurier/nirs4all-methods

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

File details

Details for the file pls4all-1.0.11-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for pls4all-1.0.11-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 292bdd7a4397143ed189b255fa6a18f33a5e1a63285da68765081e11df87c6a8
MD5 3bbdea2a7664c6ff19945b03a1e4038b
BLAKE2b-256 19385901c90632875c6fc58dc556e1ad597f74bbfc798fe14b9d723fcaa56c5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pls4all-1.0.11-py3-none-macosx_11_0_universal2.whl:

Publisher: release-python.yml on GBeurier/nirs4all-methods

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

Release history Release notifications | RSS feed

1.0.18

7 files

1.0.17

7 files

1.0.16

7 files

1.0.15

7 files

1.0.13

7 files

1.0.12

7 files

This release

1.0.11 This release

7 files

1.0.10

7 files

1.0.9

7 files

1.0.8

7 files

1.0.7

7 files

1.0.6

7 files

1.0.5

7 files

1.0.2

7 files

1.0.1

7 files

0.99.0

7 files

0.97.3

7 files

0.97.2

7 files

0.97.1

7 files

0.97.0

7 files

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