Logo of nirs4all-methods

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
  • Migrating to ABI 2.0 — the n4m.<role> namespace
  • 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
    • ridge_active_superblock — n4m.compose.aom_superblock.ridge_active_superblock
    • ridge_global — n4m.model_selection.aom_search.ridge_global
    • ridge_mkl_superblock — n4m.compose.aom_superblock.ridge_mkl_superblock
    • ridge_superblock — n4m.compose.aom_superblock.ridge_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)
    • asha — asynchronous successive halving (pruner)
    • 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
    • cmaes — separable CMA-ES (sampler)
    • continuum_regression — Continuum Regression (Stone & Brooks 1990)
    • cppls — Powered PLS (Indahl 2005)
    • di_pls — Domain-Invariant PLS (di-PLS)
    • pls_diagnostics — n4m.metrics.diagnostics.pls_diagnostics
    • regression_metrics — n4m.metrics.scoring.regression_metrics
    • 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 — genetic algorithm (sampler)
    • ga_select — GA-PLS — Genetic Algorithm variable selection
    • gp_ei — Gaussian-process Bayesian optimization (Expected Improvement)
    • gpr_pls — Gaussian Process on PLS scores
    • group_sparse_pls — Group-sparse PLS (Liquet 2016)
    • hyperband — Hyperband bracketed successive halving (pruner)
    • 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)
    • lhs — Latin Hypercube sampling
    • lw_pls — Locally-Weighted PLS (LW-PLS)
    • mb_pls — Multi-block PLS (Westerhuis 1998)
    • median — median stopping rule (pruner)
    • 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)
    • Optimization role — native hyperparameter finetuning
    • 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 — particle swarm optimization (sampler)
    • pso_select — PSO-PLS — Particle Swarm Optimisation
    • racing — Hoeffding racing (pruner)
    • random — uniform random search
    • 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)
    • sobol — Sobol low-discrepancy sequence
    • 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
    • ternary — unimodal integer search
    • tpe — Tree-structured Parzen Estimator (sampler)
    • hotelling_t2 — n4m.outlier_detection.hotelling_t2
    • q_residuals — n4m.outlier_detection.q_residuals
    • signal_type_detector — n4m.transform.signal_conversion.signal_type_detector
    • transfer_metrics — n4m.domain_adaptation.metrics.transfer_metrics
    • 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
    • transform — fit/transform feature transforms
    • augmentation — apply-only training-time perturbations
    • estimators — supervised predictors (fit/predict)
    • feature_selection — variable selectors
    • model_selection — splitters, AOM search/campaign, sweep
    • domain_adaptation — calibration transfer / standardization
    • outlier_detection — sample-level screeners + Q/T²
    • ensemble — bagging / boosting / stacking / AOM blenders
    • compose — AOM operator superblocks
    • metrics — scoring + diagnostics
    • decomposition — flexible PCA / SVD
    • lowlevel — sufficient-statistics substrate
  • 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

 
  • ← racing — Hoeffding racing (pruner)
  • random_frog_select — Random Frog →

random — uniform random search¶

Role: optimization · kind: n4m_sampler_kind_t = N4M_SAMPLER_RANDOM · since: ABI 2.1 (F0)

Uniform random sampling over the typed search space. Each parameter is drawn independently from its declared distribution: uniform for int/float, log-uniform for log_int/log_float, uniform-over-choices for categorical/ordinal, and (for sorted_tuple) a sorted vector of uniform draws. Conditional parameters are activated per their condition_in/_not_in constraint; mutex/requires/exclude constraints are enforced by bounded rejection sampling.

Random search is the default non-adaptive baseline and the startup-seeding strategy for the adaptive samplers. It is competitive with grid search at a fraction of the cost when only a few hyperparameters matter, per Bergstra & Bengio (2012).

Usage (C ABI)¶

n4m_search_space_t* space = NULL;
n4m_search_space_create(&space);
n4m_search_space_add_int(space, "n_components", 1, 30, 1, /*log=*/0);
n4m_search_space_add_float(space, "alpha", 1e-4, 1e0, 0.0, /*log=*/1);

n4m_optimizer_options_t opts;
n4m_optimizer_options_init(&opts);          /* sampler=random, pruner=none */
opts.seed = 42;

n4m_optimizer_t* opt = NULL;
n4m_optimizer_create(ctx, space, &opts, &opt);
for (int i = 0; i < n_trials; ++i) {
    n4m_trial_t* t = NULL;
    n4m_optimizer_ask(opt, &t);
    int64_t nc; n4m_trial_get_int(t, "n_components", &nc);
    /* ... host evaluates, obtains `score` ... */
    int64_t id; n4m_trial_get_id(t, &id);
    n4m_optimizer_tell(opt, id, score);
}
n4m_trial_t* best; double best_score;
n4m_optimizer_best(opt, &best, &best_score);

Parity¶

  • Tier C (self-consistency + regret): a random study replays bit-identically for a fixed seed, and reaches a known optimum within the expected budget on benchmark spaces.

  • Cross-binding: identical seed → identical trial sequence across all bindings (1e-12), via the shared n4m_rng (splitmix64).

References¶

  • Bergstra & Bengio, Random Search for Hyper-Parameter Optimization, JMLR 13 (2012), 281–305. bergstra2012random

 
  • ← racing — Hoeffding racing (pruner)
  • random_frog_select — Random Frog →
©2026, G. Beurier and contributors. | Powered by Sphinx 8.2.3 & Alabaster 1.0.0 | Page source