nirs4all-methods

Portable PLS / NIRS engine in C++17 with a stable C ABI and thin first-class bindings for Python, R, MATLAB, JavaScript, Android, Go, Rust, Julia, Ruby, .NET, Lua, Nim.

Navigation

  • ABI — Reference
  • ABI — Stability Policy
  • ABI — Changes Log
  • What is pls4all?
  • Getting started
  • Core concepts
  • Overview
  • Memory Model
  • Error Model
  • Threading
  • Serialization
  • Benchmarks
  • Benchmark overview
  • Cross-binding benchmark — parity + timing (1 thread)
  • Cross-binding benchmark — thread sweep
  • Cross-binding benchmark — methodology
  • GitHub Pages dashboard (methods.nirs4all.org)
  • Methods catalogue
    • aom_chain_ridge_pls - strict-chain AOM Ridge-PLS
    • aom_chain_sweep_run - user-defined native AOM chain sweep
    • aom_operator_pls_stack - native AOM operator PLS score stack
    • aom_pls — AOM-PLS (global adaptive operator selection)
    • AOM PLS Superblock
    • aom_preprocess — AOM (Adaptive Operator Mixture) preprocessing bank
    • AOM Ridge Active Superblock
    • aom_ridge_blender - native AOM Ridge OOF simplex blender
    • aom_ridge_global - strict-linear AOM Ridge global selector
    • aom_ridge_mkl_superblock - strict-linear AOM Ridge MKL-light superblock
    • aom_ridge_pls_superblock - strict-linear AOM Ridge-PLS superblock
    • aom_ridge_superblock - strict-linear AOM Ridge superblock
    • aom_robust_hpo - native AOM robust-HPO preprocessing screen
    • aom_staged_chain_campaign - staged strict-chain cartesian screen/refit
    • aom_sweep_run - configurable native AOM preprocessing sweep
    • approximate_press — Approximate PRESS (leave-one-out by hat-matrix)
    • aug_band_mask — Band Masking
    • aug_band_perturb — Band Perturbation Augmenter
    • aug_batch_effect — Batch Effect Augmenter
    • aug_channel_dropout — Channel Dropout
    • aug_dead_band — Dead Band Augmenter
    • aug_detector_rolloff — Detector Roll Off Augmenter
    • aug_edge_artifacts — Edge Artifacts Augmenter
    • aug_edge_curve — Edge Curvature Augmenter
    • aug_emsc_distort — E M S C Distortion Augmenter
    • aug_gauss_jitter — Gaussian Jitter
    • aug_gaussian_noise — Gaussian additive-noise augmentation
    • aug_hetero_noise — Heteroscedastic Noise Augmenter
    • aug_instrument_broaden — Instrumental Broadening Augmenter
    • aug_linear_drift — Linear baseline-drift augmentation
    • aug_local_clip — Local Clip
    • aug_local_mixup — Local Mixup Augmenter
    • aug_local_warp — Local Warp Augmenter
    • aug_magnitude_warp — Magnitude Warp
    • aug_mixup — Mixup augmentation
    • aug_moisture — Moisture Augmenter
    • aug_multiplicative_noise — Multiplicative Noise
    • aug_particle_size — Particle Size Augmenter
    • aug_path_length — Path Length Augmenter
    • aug_poly_drift — Polynomial Baseline Drift
    • aug_random_x_op — Random X Operation
    • aug_rotate_translate — Rotate Translate Augmenter
    • aug_scatter_sim — Scatter Simulation M S C
    • aug_spike_noise — Spike Noise
    • aug_spline_curve_simplify — Spline Curve Simplification Augmenter
    • aug_spline_smooth — Spline Smoothing Augmenter
    • aug_spline_x_perturb — Spline X Perturbation Augmenter
    • aug_spline_x_simplify — Spline X Simplification Augmenter
    • aug_spline_y_perturb — Spline Y Perturbation Augmenter
    • aug_stray_light — Stray Light Augmenter
    • aug_temperature — Temperature Augmenter
    • aug_truncated_peak — Truncated Peak Augmenter
    • aug_unsharp_mask — Unsharp Mask
    • aug_wavelength_shift — Wavelength Shift
    • aug_wavelength_stretch — Wavelength Stretch
    • bagging_pls — Bagging PLS
    • bipls_select — biPLS — Backward Interval PLS
    • boosting_pls — Boosting PLS
    • bve_select — BVE — Backward Variable Elimination
    • cars_select — CARS — Competitive Adaptive Reweighted Sampling
    • continuum_regression — Continuum Regression (Stone & Brooks 1990)
    • cppls — Powered PLS (Indahl 2005)
    • di_pls — Domain-Invariant PLS (di-PLS)
    • ds — Direct Standardisation
    • ecr — ECR — Elastic Component Regression
    • emcuve_select — EMCUVE — Ensemble MC-UVE
    • filter_composite — Composite Filter
    • filter_correlation — Correlation Filter
    • filter_leverage — High Leverage Filter
    • filter_quality — Spectral Quality Filter
    • filter_variance — Variance Filter
    • filter_x_outlier — X Outlier Filter
    • filter_y_outlier — Y Outlier Filter
    • fused_sparse_pls — Fused-sparse PLS
    • ga_select — GA-PLS — Genetic Algorithm variable selection
    • gpr_pls — Gaussian Process on PLS scores
    • group_sparse_pls — Group-sparse PLS (Liquet 2016)
    • interval_generator — Interval Generator
    • interval_select — iPLS — Interval PLS (moving-window)
    • ipw_select — IPW — Iterative Predictor Weighting
    • irf_select — IRF — Iterative Random Forest
    • iriv_select — IRIV — Iteratively Retaining Informative Variables
    • kernel_pls_rbf — Kernel PLS (Rosipal & Trejo 2001)
    • lw_pls — Locally-Weighted PLS (LW-PLS)
    • mb_pls — Multi-block PLS (Westerhuis 1998)
    • mir_pls — MIR-PLS (Mid-InfraRed PLS, regularised)
    • missing_aware_nipals — Missing-aware NIPALS
    • moment_stack — OOF stack over native moment heads
    • moments
    • n_pls — N-way PLS (Trilinear PLS, Bro 1996)
    • o2pls — O2-PLS (two-way orthogonal)
    • on_pls — OnPLS (Orthogonal N-block PLS)
    • one_se_rule — One-SE rule for component selection
    • opls — Orthogonal PLS (OPLS)
    • pcr — Principal Components Regression
    • pds — Piecewise Direct Standardisation
    • pls — PLS regression (SIMPLS)
    • pls_cox — PLS-Cox (survival regression)
    • pls_diagnostic_dmodx — DModX (distance to the model in X)
    • pls_diagnostic_q — Q residual (squared prediction error)
    • pls_diagnostic_t2 — Hotelling T² score
    • pls_glm — PLS-GLM (Generalised Linear Model PLS)
    • pls_lda — PLS-LDA
    • pls_logistic — PLS-logistic regression
    • pls_monitoring — PLS monitoring (T² + Q with control limits)
    • pls_qda — PLS-QDA
    • pop_pls — POP-PLS (per-component operator selection)
    • pp_airpls — Air P L S
    • pp_area — Area Normalization
    • pp_arpls — Ar P L S
    • pp_asls — As L S
    • pp_baseline — Baseline Center
    • pp_beads — B E A D S
    • pp_cow_align — Correlation Optimized Warping
    • pp_crop — Crop Transformer
    • pp_derivate — Derivate
    • pp_detrend — De-trending
    • pp_direct_standardization — Direct Standardization
    • pp_dtw_align — Dynamic Time Warping Alignment
    • pp_emsc — Extended Multiplicative Scatter Correction (EMSC)
    • pp_epo — E P O
    • pp_fck_static — F C K Static Transformer
    • pp_first_derivative — First derivative
    • pp_flex_pca — Flexible P C A
    • pp_flex_svd — Flexible S V D
    • pp_frac_to_pct — Fraction To Percent
    • pp_from_absorbance — From Absorbance
    • pp_gaussian — Gaussian smoothing
    • pp_haar — Haar
    • pp_iasls — I As L S
    • pp_icoshift_align — Icoshift Alignment
    • pp_imodpoly — I Mod Poly
    • pp_kbins_disc — Integer K Bins Discretizer
    • pp_kubelka_munk — Kubelka Munk
    • pp_local_centering — Local Centering
    • pp_localized_msc — Localized M S C
    • pp_log — Log Transform
    • pp_lsnv — L S N V
    • pp_modpoly — Mod Poly
    • pp_msc — Multiplicative Scatter Correction (MSC)
    • pp_normalize — Normalize
    • pp_norris_williams — Norris Williams
    • pp_osc — O S C
    • pp_pct_to_frac — Percent To Fraction
    • pp_piecewise_direct_standardization — Piecewise Direct Standardization
    • pp_piecewise_msc — Piecewise M S C
    • pp_piecewise_snv — Piecewise S N V
    • pp_range_disc — Range Discretizer
    • pp_resample — Resample Transformer
    • pp_resampler — Resampler
    • pp_rnv — Robust Normal Variate (RNV)
    • pp_robust_direct_standardization — Robust Direct Standardization
    • pp_rolling_ball — Rolling Ball
    • pp_saps — Score Augmented Projection Standardization
    • pp_savgol — Savitzky–Golay smoothing / derivative
    • pp_second_derivative — Second derivative
    • pp_simple_scale — Simple Scale
    • pp_slope_bias — Slope Bias Correction
    • pp_snip — S N I P
    • pp_snv — Standard Normal Variate (SNV)
    • pp_to_absorbance — To Absorbance
    • pp_vsn — Variable Sorting Normalization
    • pp_wavelet — Wavelet
    • pp_wavelet_denoise — Wavelet Denoise
    • pp_wavelet_features — Wavelet Features
    • pp_wavelet_pca — Wavelet P C A
    • pp_wavelet_svd — Wavelet S V D
    • pp_weighted_snv — Weighted S N V
    • pp_xcorr_align — Cross Correlation Alignment
    • pso_select — PSO-PLS — Particle Swarm Optimisation
    • random_frog_select — Random Frog
    • random_subspace_pls — Random-subspace PLS
    • randomization_select — Randomisation test (Y-permutation)
    • recursive_pls — Recursive (moving-window) PLS
    • rep_select — REP — Recursive Elimination of Predictors
    • ridge - direct closed-form Ridge regression
    • ridge_pls — Ridge-augmented PLS
    • robust_pls — Robust PLS (Partial Robust M-regression)
    • rosa — ROSA (Response-Oriented Sequential Alternation)
    • scars_select — SCARS — Stability-CARS
    • shaving_select — Shaving (recursive elimination)
    • sipls_select — siPLS — Synergy Interval PLS
    • so_pls — Sequential and Orthogonalised PLS (SO-PLS)
    • spa_select — SPA — Successive Projections Algorithm
    • sparse_pls_da — Sparse PLS-DA (Lê Cao 2008)
    • sparse_simpls — Sparse SIMPLS (Chun & Keleş 2010)
    • split_binned_strat_group_kfold — Binned Stratified Group K Fold Splitter
    • split_kbins_stratified — K Bins Stratified Splitter
    • split_kennard_stone — Kennard Stone Splitter
    • split_kmeans — K Means Splitter
    • split_split_splitter — S Plit Splitter
    • split_spxy — S P X Y Splitter
    • split_spxy_fold — S P X Y Fold Splitter
    • split_spxy_g_fold — S P X Y Group Fold Splitter
    • split_systematic_circular — Systematic Circular Splitter
    • st_select — ST-PLS — Score Threshold selection
    • stability_select — MC-UVE (Monte-Carlo coefficient stability)
    • sweep_run
    • t2_select — Hotelling T² loading selection
    • uve_select — UVE — Uninformative Variable Elimination
    • variable_select_coef — Coefficient-magnitude selection
    • variable_select_sr — Selectivity Ratio
    • variable_select_vip — VIP (Variable Importance in Projection)
    • vip_spa_select — VIP-seeded SPA
    • vissa_select — VISSA — Variable Iterative Space-Shrinkage
    • weighted_pls — Sample-weighted PLS
    • wvc_select — WVC — Weighted Variable Contribution
    • wvc_threshold_select — WVC-threshold selection
    • Core PLS
    • Sparse
    • Ensemble
    • Robust / weighted
    • Nonlinear / local
    • Multi-block / cross-modal
    • Calibration transfer
    • Classification & GLM
    • Missing data
    • Regularised
    • Diagnostic
    • Variable selector
    • Preprocessing
    • Baseline correction
    • Signal transforms
    • Feature extraction
    • Augmentation
    • Sample / feature filters
    • Splitters
    • Utilities
  • Python binding
  • r binding
  • MATLAB / Octave binding
  • js binding
  • Parity methodology
  • Parity tolerances
  • Development workflow
  • Development — Build
  • Read the Docs
  • Development — Testing
  • Stabilisation plan — parity, dashboard and releases
  • Development — Style
  • Development — Release Process

Quick search

 
  • ← pp_derivate — Derivate
  • pp_direct_standardization — Direct Standardization →

pp_detrend — De-trending¶

Group: Baseline correction · Binding: n4m.sklearn.Detrend · C ABI: n4m_pp_detrend_*

Description¶

Polynomial baseline subtraction.

Parameters¶

Name

Type

Default

polyorder

int

1

Explanations¶

Bibliographic source¶

Barnes, R. J., Dhanoa, M. S. & Lister, S. J. (1989). Applied Spectroscopy 43(5), 772–777.

Mathematical principle¶

Fits and subtracts a low-order polynomial (commonly linear or quadratic) along the wavelength axis of each spectrum, removing wavelength-dependent baseline curvature that SNV alone leaves behind.

Implementation¶

C ABI n4m_pp_detrend_* in libn4m (create / apply / destroy lifecycle), wrapped by n4m.sklearn.Detrend. The same numerical kernel backs every language binding.

Usage¶

from n4m.sklearn import Detrend
op = Detrend()
X_transformed = op.fit_transform(X)

Benchmarks¶

Adaptive wall-clock per cell measured against full_matrix.csv. Only backends that implement this method are listed; libraries without the method are omitted.

Verdict  ·  ✓ ref / ≈ ref / ~ shape mark a reference-gate pass at strict / relaxed / qualitative tolerance  ·  ✓ bind = pls4all binding agrees with the C++ baseline  ·  ⇄ cross-check = documented by-design selector/RNG/model, noncanonical API/facade convention, or secondary oracle  ·  ✗ divergent  ·  ⚠ error  ·  — not run. The fastest backend per column is marked 🏆.

Reference gate: strict — numeric equivalence (rmse_rel_tol ≤ 1e-12).

BackendParity50×250 (ms)250×50 (ms)
C++ native · libn4m
pls4all.cpp.blas✓ ref0.04 ms—
pls4all.cpp.blas+omp✓ ref0.04 ms0.06 ms
pls4all.cpp.omp✓ ref0.03 ms🏆—
pls4all.cpp.ref✓ ref0.06 ms0.06 ms
Python · pls4all
pls4all.python✓ bind0.03 ms0.03 ms🏆
pls4all.sklearn✓ bind0.03 ms0.03 ms
Python · external
nirs4allsource0.13 ms0.15 ms
ref.python_numpysource——

See also: methods index · interactive dashboard

 
  • ← pp_derivate — Derivate
  • pp_direct_standardization — Direct Standardization →
©2026, G. Beurier and contributors. | Powered by Sphinx 8.2.3 & Alabaster 1.0.0 | Page source