spa_select — SPA — Successive Projections Algorithm¶
Group: Variable selector · Registry tolerance: 1e-06
Description¶
SPA Successive Projections (§18 Phase 5e)
Registry note — R
plsVarSel::spa_plsrandomization-based SPA (Forina et al.) — paired Wilcoxon variable importance, p < 0.05 survivor set (fallback to top-ncompp-values). Default_spa_select_pls4allpath mirrors the same R call with seed=11, giving bit-exact mask parity. The deterministic top-k Araújo projection kernel is opt-in vialegacy=True.
Parameters¶
Name |
Type |
Default |
Notes |
|---|---|---|---|
|
|
|
current public binding signature |
|
|
|
current public binding signature |
Explanations¶
Bibliographic source¶
Araújo, M. C. U., Saldanha, T. C. B., Galvão, R. K. H., Yoneyama, T., Chame, H. C. & Visani, V. (2001). The successive projections algorithm for variable selection in spectroscopic multicomponent analysis. Chemometrics and Intelligent Laboratory Systems 57(2), 65–73. Verified primary link: https://doi.org/10.1016/S0169-7439(01)00119-8.
Mathematical principle¶
SPA is a greedy forward selector that seeks minimally collinear features. Starting from the feature with largest coefficient (or user-supplied seed), at each step it adds the feature whose direction is maximally orthogonal to all previously-selected features. Formally, at step \(m\) it picks \(j^{\star} = \arg\max_j \| \mathbf{P}_{S_{m-1}}^{\perp} \mathbf{x}_j \|_2\), where \(\mathbf{P}_{S}^{\perp}\) projects onto the orthogonal complement of the span of the already-selected features.
This produces a feature subset that is well-conditioned for downstream regression: the inverse \((\mathbf{X}_S^{\top}\mathbf{X}_S)^{-1}\) has small condition number by construction. SPA is therefore particularly effective when followed by MLR (or PLS with very few components) on the selected subset.
Stops at a user-specified top-\(k\). Computational cost: \(O(k\, n\, p)\).
Appropriate uses¶
Selecting minimally collinear wavelengths for compact spectrometer or interpretable calibration designs.
Limits and validation¶
SPA’s projection criterion is only indirectly response-aware and the starting variable/target subset size can change the result.
Implementation¶
n4m_feature_selection_spa_select. Reference: R plsVarSel.
Sources and provenance¶
Current implementation: cpp/src/core/spa_selection.cpp.
API and bindings¶
C ABI (ABI 2): n4m_feature_selection_spa_select. Use the linked public header for the exact signature, configuration, and result handles.
Python (verified public re-export):
from n4m.feature_selection.wrapper import SPA
Source signature: SPA(top_k: int, *, n_components: int = 2) (n4m/_impl/selection.py).
R (source-verified): spa_select(X, Y, n_components, top_k).
The source signature has additional required inputs, so no example call is fabricated.
MATLAB / Octave (source-verified): spa_select(X, Y, n_components, top_k).
The source signature has additional required inputs, so no example call is fabricated.
Registry parity references 📐
📐
ref.r_plsvarsel(R · r) —plsVarSel0.10.0 · strict (rmse_rel ≤ 1e-06) — RplsVarSel::spa_pls— Successive Projections Algorithm.
Benchmarks¶
Archived measurement identity. Backend labels in this table are the raw IDs recorded when the benchmark ran (including historical pls4all.* IDs). They preserve measurement provenance and do not describe a current public Python, R, or MATLAB binding; use the source-verified API and bindings section above for current entry points.
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 = archived binding-harness result 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-06).
Rows tagged with 📐 are the canonical parity references for this method (declared in parity_timing.registry). C++ and external rows show reference parity; archived language-harness rows show binding parity against the C++ backend. Hover the icon for role and tolerance band.
| Backend | Parity | 200×40 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ J 1.00 | 499.6 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ J 1.00 | 515.0 ms |
pls4all.sklearn | ⇄ J 0.12 | 1.97 ms🏆 |
| R · archived pls4all benchmark | ||
pls4all.R | ⇄ J 0.12 | 4.72 ms |
pls4all.R.formula | ⇄ J 0.12 | 6.23 ms |
pls4all.R.mdatools | ⇄ J 0.12 | 5.86 ms |
pls4all.R.pls | ⇄ J 0.12 | 5.75 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 104.0 ms |
| Backend | Parity | 200×40 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ J 1.00 | 819.9 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ J 1.00 | 530.6 ms |
pls4all.sklearn | ⇄ J 0.12 | 1.90 ms🏆 |
| R · archived pls4all benchmark | ||
pls4all.R | ⇄ J 0.12 | 5.33 ms |
pls4all.R.formula | ⇄ J 0.12 | 5.81 ms |
pls4all.R.mdatools | ⇄ J 0.12 | 10.9 ms |
pls4all.R.pls | ⇄ J 0.12 | 6.22 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 164.5 ms |
| Backend | Parity | 200×40 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ J 1.00 | 557.0 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ J 1.00 | 514.9 ms |
pls4all.sklearn | ⇄ J 0.12 | 1.89 ms🏆 |
| R · archived pls4all benchmark | ||
pls4all.R | ⇄ J 0.12 | 4.70 ms |
pls4all.R.formula | ⇄ J 0.12 | 5.57 ms |
pls4all.R.mdatools | ⇄ J 0.12 | 5.52 ms |
pls4all.R.pls | ⇄ J 0.12 | 5.17 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 179.5 ms |
See also: benchmark overview · methods index · interactive dashboard