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
ContextandConfig(RAII lifecycle wrappers), - the PLS fit/predict surface and a scikit-learn-compatible
pls4all.sklearn.PLSRegression(and the other PLS-family estimators), - a typed
Pls4allErrorraised on any non-OK status, carrying the context'slast_errormessage.
Quick start
import numpy as np
import pls4all
from pls4all.sklearn import PLSRegression
print(pls4all.version()) # e.g. "1.0.3+abi.2.2.0"
print(pls4all.abi_version()) # (2, 2, 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:
$PLS4ALL_LIB_PATH— explicit path tolibn4mfor this package,$N4M_LIB_PATH— sharedlibn4moverride honoured by bothpls4allandn4m,pls4all/lib/libn4m*next to the installed package (wheel layout),<repo-root>/build/dev-release/cpp/src/libn4m*(developer convenience),- the standard system search path (
LD_LIBRARY_PATH, macOS rpath, WindowsPATH).
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
Built Distributions
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 pls4all-1.0.10.tar.gz.
File metadata
- Download URL: pls4all-1.0.10.tar.gz
- Upload date:
- Size: 143.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6be631ab90649c794b7a140f28160890971fe7b62711b3f271a0630323344b8f
|
|
| MD5 |
4af9c03b13e2cd72b97459dce36cc1f5
|
|
| BLAKE2b-256 |
d91b8848f4c7a06f963b498c85d301f5343afc3024fc8ed41ccf2806b3e70a5f
|
Provenance
The following attestation bundles were made for pls4all-1.0.10.tar.gz:
Publisher:
release-python.yml on GBeurier/nirs4all-methods
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pls4all-1.0.10.tar.gz -
Subject digest:
6be631ab90649c794b7a140f28160890971fe7b62711b3f271a0630323344b8f - Sigstore transparency entry: 2583421340
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-methods@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Branch / Tag:
refs/tags/v1.0.10 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pls4all-1.0.10-py3-none-win_amd64.whl.
File metadata
- Download URL: pls4all-1.0.10-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32c03c5d2cc4290067fc16b6d0aba9d6d7fa5041200489d8aeed71cb76d688ad
|
|
| MD5 |
89ee9a48e274a1960ee706e6ed54cb9a
|
|
| BLAKE2b-256 |
35b2bb40a3881ffc4139b45cdb63981849a46127814e1bcc62c9a65d028f1266
|
Provenance
The following attestation bundles were made for pls4all-1.0.10-py3-none-win_amd64.whl:
Publisher:
release-python.yml on GBeurier/nirs4all-methods
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pls4all-1.0.10-py3-none-win_amd64.whl -
Subject digest:
32c03c5d2cc4290067fc16b6d0aba9d6d7fa5041200489d8aeed71cb76d688ad - Sigstore transparency entry: 2583421410
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-methods@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Branch / Tag:
refs/tags/v1.0.10 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pls4all-1.0.10-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: pls4all-1.0.10-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 5.1 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
183e76045879a4e90ef5e7836f896f251fe36f86618955327c8092b6e013bfe9
|
|
| MD5 |
946e518a339b5e412482dd5a158206de
|
|
| BLAKE2b-256 |
f0a790bcdf3996ccef2a426ddd7aa1a563aae3fd4b5a7a5a7b8ea206157f8561
|
Provenance
The following attestation bundles were made for pls4all-1.0.10-py3-none-musllinux_1_2_x86_64.whl:
Publisher:
release-python.yml on GBeurier/nirs4all-methods
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pls4all-1.0.10-py3-none-musllinux_1_2_x86_64.whl -
Subject digest:
183e76045879a4e90ef5e7836f896f251fe36f86618955327c8092b6e013bfe9 - Sigstore transparency entry: 2583421383
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-methods@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Branch / Tag:
refs/tags/v1.0.10 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pls4all-1.0.10-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: pls4all-1.0.10-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 4.5 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b3a3b0ade660a8968fa9db2388004bf66e60384f96e735a559311ea00b4e8d9
|
|
| MD5 |
cc20c16a2d299f8720557a7669592249
|
|
| BLAKE2b-256 |
858b100f5a66e1d3c52ca8294fb2a1789b86a374904f3674c802c6b28c0058f6
|
Provenance
The following attestation bundles were made for pls4all-1.0.10-py3-none-musllinux_1_2_aarch64.whl:
Publisher:
release-python.yml on GBeurier/nirs4all-methods
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pls4all-1.0.10-py3-none-musllinux_1_2_aarch64.whl -
Subject digest:
6b3a3b0ade660a8968fa9db2388004bf66e60384f96e735a559311ea00b4e8d9 - Sigstore transparency entry: 2583421365
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-methods@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Branch / Tag:
refs/tags/v1.0.10 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pls4all-1.0.10-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pls4all-1.0.10-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 5.2 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77c3d2e345801d54ea02ae44a0408c5d904ca66b3b94dc3c338c5a201fdcb00a
|
|
| MD5 |
0d1e6b1334c359f570a238aa454f6379
|
|
| BLAKE2b-256 |
1e80d4929ce432b541a4eb736c2bfd7273b7cdf34e0f7b7b3eaf1362c15c5766
|
Provenance
The following attestation bundles were made for pls4all-1.0.10-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
release-python.yml on GBeurier/nirs4all-methods
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pls4all-1.0.10-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
77c3d2e345801d54ea02ae44a0408c5d904ca66b3b94dc3c338c5a201fdcb00a - Sigstore transparency entry: 2583421399
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-methods@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Branch / Tag:
refs/tags/v1.0.10 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pls4all-1.0.10-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: pls4all-1.0.10-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 4.0 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f055d09339ac6387078be59a7900458a499cb58b0c8d51ba610f8ae81e092f3
|
|
| MD5 |
57600caa1f55997a0f836a01cc07e408
|
|
| BLAKE2b-256 |
308676fbaef7cd5425e13ad444e36020959aed49449b59a29f4d783d6a2d9574
|
Provenance
The following attestation bundles were made for pls4all-1.0.10-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
release-python.yml on GBeurier/nirs4all-methods
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pls4all-1.0.10-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
0f055d09339ac6387078be59a7900458a499cb58b0c8d51ba610f8ae81e092f3 - Sigstore transparency entry: 2583421391
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-methods@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Branch / Tag:
refs/tags/v1.0.10 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Trigger Event:
push
-
Statement type:
File details
Details for the file pls4all-1.0.10-py3-none-macosx_11_0_universal2.whl.
File metadata
- Download URL: pls4all-1.0.10-py3-none-macosx_11_0_universal2.whl
- Upload date:
- Size: 7.9 MB
- Tags: Python 3, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
645f069bdfec65f97144401918b70130cfb7d633bda5be8a01649cd715f67092
|
|
| MD5 |
ff24998aaf4ca1a4cfe75604d89963f7
|
|
| BLAKE2b-256 |
2719097717008754d1d73dddfa9fc39f6ecdbd15263d23d135e4d64982445e96
|
Provenance
The following attestation bundles were made for pls4all-1.0.10-py3-none-macosx_11_0_universal2.whl:
Publisher:
release-python.yml on GBeurier/nirs4all-methods
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pls4all-1.0.10-py3-none-macosx_11_0_universal2.whl -
Subject digest:
645f069bdfec65f97144401918b70130cfb7d633bda5be8a01649cd715f67092 - Sigstore transparency entry: 2583421413
- Sigstore integration time:
-
Permalink:
GBeurier/nirs4all-methods@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Branch / Tag:
refs/tags/v1.0.10 - Owner: https://github.com/GBeurier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@f84a55d0b3a540940cd0e1f27d8df8c30416d87d -
Trigger Event:
push
-
Statement type: