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, Octave and JavaScript / WebAssembly. Other bindings are archived prototypes.

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
  • Fitted-model wire serialization
  • R2 native artifact preflight
  • 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)
  • Global bibliography
  • Methods catalogue
    • AOM calibration contracts (ABI 2.15)
    • aom_chain_ridge_pls — n4m.model_selection.aom_search.aom_chain_ridge_pls
    • aom_chain_sweep — n4m.model_selection.aom_search.aom_chain_sweep
    • aom_operator_pls_stack — n4m.ensemble.aom_operator_pls_stack
    • aom_pls — AOM-PLS (global adaptive operator selection)
    • aom_pls_superblock — n4m.compose.aom_superblock.aom_pls_superblock
    • aom_chain_fixed_fit — n4m.model_selection.aom_search.aom_chain_fixed_fit
    • aom_chain_screen_refit — n4m.model_selection.aom_campaign.aom_chain_screen_refit
    • calibration — n4m.model_selection.aom_calibration.calibration
    • linear_ridge_stack — n4m.ensemble.linear_ridge_stack
    • linear_stack_compress — n4m.ensemble.linear_stack_compress
    • 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
    • ridge_active_superblock — n4m.compose.aom_superblock.ridge_active_superblock
    • aom_ridge_blender — n4m.ensemble.aom_ridge_blender
    • ridge_global — n4m.model_selection.aom_search.ridge_global
    • ridge_mkl_superblock — n4m.compose.aom_superblock.ridge_mkl_superblock
    • aom_ridge_pls_superblock — n4m.compose.aom_superblock.aom_ridge_pls_superblock
    • ridge_superblock — n4m.compose.aom_superblock.ridge_superblock
    • robust_hpo — n4m.model_selection.aom_search.robust_hpo
    • aom_staged_chain_campaign — n4m.model_selection.aom_campaign.aom_staged_chain_campaign
    • aom_sweep — n4m.model_selection.aom_search.aom_sweep
    • approximate_press — PRESS by leave-one-out refitting
    • asha — asynchronous successive halving (pruner)
    • aug_band_mask — Random contiguous-band masking
    • aug_band_perturb — Local band gain-and-offset perturbation
    • aug_batch_effect — Offset, slope, and gain batch effects
    • aug_channel_dropout — Independent spectral-channel dropout
    • aug_dead_band — Random noisy detector dead bands
    • aug_detector_rolloff — Detector sensitivity roll-off artifact
    • aug_edge_artifacts — Configured pipeline of four edge artifacts
    • aug_edge_curve — Smooth detector-edge curvature
    • aug_emsc_distort — Random EMSC-like affine and polynomial distortion
    • aug_gauss_jitter — Random Gaussian smoothing jitter
    • aug_gaussian_noise — Gaussian additive noise scaled to each spectrum
    • aug_hetero_noise — Signal-dependent heteroscedastic noise
    • aug_instrument_broaden — Gaussian instrumental broadening from FWHM
    • aug_linear_drift — Random affine baseline drift
    • aug_local_clip — Random local 90th-percentile clipping
    • aug_local_mixup — Nearest-neighbor constrained mixup
    • aug_local_warp — Piecewise-linear local wavelength warp
    • aug_magnitude_warp — Smooth multiplicative magnitude warp
    • aug_mixup — Within-batch convex mixup of spectra
    • aug_moisture — Water-activity and moisture-band perturbation
    • aug_multiplicative_noise — Per-spectrum multiplicative gain noise
    • aug_particle_size — Particle-size and path-length scatter heuristic
    • aug_path_length — Multiplicative path-length perturbation
    • aug_poly_drift — Random polynomial baseline drift
    • aug_random_x_op — Independent random elementwise arithmetic
    • aug_rotate_translate — Random hinged rotation-and-translation pattern
    • aug_scatter_sim — MSC-style affine scatter simulation
    • aug_spike_noise — Sparse impulsive spike injection
    • aug_spline_curve_simplify — Curve-control cubic-spline simplification
    • aug_spline_smooth — Deterministic natural-cubic spline smoothing
    • aug_spline_x_perturb — Spline-based x-axis perturbation
    • aug_spline_x_simplify — Cubic-spline reconstruction from sparse x controls
    • aug_spline_y_perturb — Smooth additive spline perturbation
    • aug_stray_light — Stray-light distortion in transmittance space
    • aug_temperature — Region-specific temperature perturbation heuristic
    • aug_truncated_peak — Off-range Gaussian peak tails
    • aug_unsharp_mask — Unsharp spectral masking
    • aug_wavelength_shift — Rigid wavelength-axis shift
    • aug_wavelength_stretch — Wavelength-axis stretch about its center
    • 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)
    • Method documentation coverage
    • cppls — Canonical Powered PLS (CPPLS)
    • di_pls — Domain-Invariant PLS (di-PLS)
    • adjusted_rand_index — n4m.metrics.clustering.adjusted_rand_index
    • bh_adjust — n4m.metrics.multiple_testing.bh_adjust
    • jaccard_matrix — n4m.cluster.jaccard_matrix
    • correlation_test — n4m.metrics.statistics.correlation_test
    • energy_distance — n4m.stats.energy_distance
    • factor_association_exact — n4m.metrics.statistics.factor_association_exact
    • group_means — n4m.stats.group_means
    • hdbscan — n4m.cluster.hdbscan
    • holm_adjust — n4m.metrics.multiple_testing.holm_adjust
    • linear_sum_assignment — n4m.optimize.linear_sum_assignment
    • pca_monitor — n4m.stats.pca_monitor
    • permanova — n4m.stats.permanova
    • permdisp — n4m.stats.permdisp
    • pls_diagnostics — n4m.metrics.diagnostics.pls_diagnostics
    • qualification — n4m.metrics.preflight.qualification
    • regression_metrics — n4m.metrics.scoring.regression_metrics
    • regression_scores — n4m.stats.regression_scores
    • one_way_reml — n4m.stats.variance_components.one_way_reml
    • ds — Direct Standardisation
    • ecr — ECR — Elastic Component Regression
    • emcuve_select — EMCUVE — Ensemble MC-UVE
    • filter_composite — Boolean composition of sample keep masks
    • filter_correlation — Absolute Pearson-correlation feature filter
    • filter_leverage — Hat-matrix or PCA-score leverage filter
    • filter_quality — Rule-based row-level spectral quality filter
    • filter_variance — Population-variance feature filter
    • filter_x_outlier — Multistrategy X-space outlier filter
    • filter_y_outlier — Univariate target 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 — Fixed and overlapping interval expansion
    • interval_select — iPLS — Interval PLS (moving-window)
    • ipw_select — IPW — Iterative Predictor Weighting
    • irf_select — Interval Random Frog (IRF) selection
    • 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 inverse-regression variant
    • missing_aware_nipals — Missing-aware NIPALS
    • moment_stack — n4m.ensemble.moment_stack
    • pls_regression — n4m.estimators.regression.latent.pls_regression
    • ridge — n4m.estimators.regression.regularized.ridge
    • 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 — Deviance-residual PLS-Cox 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 generalized linear regression
    • 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 — Adaptive iteratively reweighted penalized least squares (airPLS)
    • pp_area — Area normalization
    • pp_arpls — Asymmetrically reweighted penalized least squares (arPLS)
    • pp_asls — Asymmetric least-squares baseline correction (AsLS)
    • pp_baseline — Training-set column mean centering
    • pp_beads — Baseline estimation and denoising with sparsity (BEADS)
    • pp_cow_align — Correlation optimized warping (COW)
    • pp_crop — Wavelength-column cropping
    • pp_derivate — Order-\(d\) finite-difference derivative
    • pp_detrend — Polynomial spectral detrending
    • pp_direct_standardization — Direct standardization (DS)
    • pp_dtw_align — Dynamic time warping spectral alignment
    • pp_emsc — Extended multiplicative scatter correction (EMSC)
    • pp_epo — External parameter orthogonalization (EPO)
    • pp_fck_static — Static fractional convolutional-kernel bank
    • pp_first_derivative — Shape-preserving first numerical derivative
    • pp_flex_pca — Flexible principal component analysis
    • pp_flex_svd — Flexible truncated singular-value decomposition
    • pp_frac_to_pct — Fraction-to-percent signal conversion
    • pp_from_absorbance — Absorbance-to-reflectance/transmittance conversion
    • pp_gaussian — Gaussian smoothing and derivative filtering
    • pp_haar — Single-level Haar discrete wavelet transform
    • pp_iasls — Improved asymmetric least-squares baseline correction (IAsLS)
    • pp_icoshift_align — Interval correlation optimized shifting (icoshift-style)
    • pp_imodpoly — Improved modified-polynomial baseline correction (IModPoly)
    • pp_kbins_disc — Per-feature integer k-bin discretization
    • pp_kubelka_munk — Kubelka–Munk remission transform
    • pp_local_centering — Source-to-target local centering
    • pp_localized_msc — Localized moving-window multiplicative scatter correction
    • pp_log — Element-wise logarithmic transform
    • pp_lsnv — Local standard normal variate (LSNV)
    • pp_modpoly — Modified-polynomial baseline correction (ModPoly)
    • pp_msc — Multiplicative scatter correction (MSC)
    • pp_normalize — Column-wise normalization
    • pp_norris_williams — Norris–Williams segment-gap derivative
    • pp_osc — Orthogonal signal correction (OSC)
    • pp_pct_to_frac — Percent-to-fraction signal conversion
    • pp_piecewise_direct_standardization — Piecewise direct standardization (PDS)
    • pp_piecewise_msc — Piecewise multiplicative scatter correction
    • pp_piecewise_snv — Piecewise standard normal variate
    • pp_range_disc — Fixed-edge range discretization
    • pp_resample — Fixed-length normalized-axis resampling
    • pp_resampler — Wavelength-grid resampler
    • pp_rnv — Robust normal variate (RNV)
    • pp_robust_direct_standardization — Trimmed robust direct standardization
    • pp_rolling_ball — Rolling-ball morphological baseline correction
    • pp_saps — Score-augmented projection standardization (SAPS)
    • pp_savgol — Savitzky–Golay smoothing and differentiation
    • pp_second_derivative — Shape-preserving second numerical derivative
    • pp_simple_scale — Column-wise min–max scaling to [0, 1]
    • pp_slope_bias — Slope-and-bias prediction correction
    • pp_snip — Statistics-sensitive nonlinear iterative peak clipping (SNIP)
    • pp_snv — Standard normal variate (SNV)
    • pp_to_absorbance — Reflectance/transmittance-to-absorbance conversion
    • pp_vsn — Variable-sorting normalization (VSN-style weighted SNV)
    • pp_wavelet — Single-level discrete wavelet coefficient transform
    • pp_wavelet_denoise — Multilevel wavelet VisuShrink denoising
    • pp_wavelet_features — Multilevel wavelet summary features
    • pp_wavelet_pca — PCA of multilevel wavelet coefficients
    • pp_wavelet_svd — Truncated SVD of multilevel wavelet coefficients
    • pp_weighted_snv — Weighted standard normal variate
    • pp_xcorr_align — Whole-spectrum cross-correlation alignment
    • spectral_encoding — n4m.decomposition.spectral_encoding
    • standard_scale — n4m.transform.scaling.standard_scale
    • 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
    • Current method-science reference index
    • 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)
    • LVSE and GCU spectral encoders
    • split_binned_strat_group_kfold — Binned, group-preserving round-robin folds
    • split_kbins_stratified — Continuous-target binned stratified split
    • split_kennard_stone — Kennard–Stone maximin calibration split
    • split_kmeans — K-means++ representative-sample split
    • split_split_splitter — SPlit sequential data-twinning split
    • split_spxy — SPXY joint X–Y maximin split
    • split_spxy_fold — Alternating maximin SPXY K-fold assignment
    • split_spxy_g_fold — Group-preserving SPXY K-fold assignment
    • split_systematic_circular — Systematic circular sampling over sorted targets
    • 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
    • moments — n4m.lowlevel.moments.moments
    • q_residuals — n4m.outlier_detection.q_residuals
    • ragged_summary — n4m.utilities.ragged_summary
    • signal_type_detector — n4m.transform.signal_conversion.signal_type_detector
    • sweep — n4m.model_selection.sweep.sweep
    • 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
    • cluster
    • optimize
    • stats
    • utilities
  • Python binding
  • R binding
  • MATLAB / Octave binding
  • JavaScript / WebAssembly binding
  • Parity methodology
  • Parity tolerances
  • Development workflow
  • Development — Build
  • Read the Docs
  • Development — Testing
  • Developer documentation
  • Restoring the method documentation
  • HDBSCAN for Preflight: reuse assessment and reference gate
  • Cluster matching and Gaussian null kernels: reuse assessment and reference gate
  • 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