shaving_select — Shaving (recursive elimination)¶
Group: Variable selector · Registry tolerance: 1e-06
Description¶
Shaving iterative variable trimming
Registry note — R
plsVarSel::shaving(method='SR')iterative selectivity-ratio trimming — CV-error-minimising survivor set. Default_shaving_select_pls4allpath mirrors the same R call with seed=11, giving bit-exact mask parity. The C++ step-count trajectory kernel is opt-in vialegacy=True.
Parameters¶
Name |
Type |
Default |
Notes |
|---|---|---|---|
|
|
|
current public binding signature |
|
|
|
current public binding signature |
|
|
|
current public binding signature |
|
|
|
current public binding signature |
|
|
|
current public binding signature |
Explanations¶
Bibliographic source¶
Mehmood, T., Liland, K. H., Snipen, L. & Sæbø, S. (2012). A review of variable selection methods in partial least squares regression. Chemometrics and Intelligent Laboratory Systems 118, 62–69 (§3.2 Shaving). Verified primary link: https://doi.org/10.1016/j.chemolab.2012.07.010.
Mathematical principle¶
Shaving recursively eliminates a fraction \(\rho \in (0, 1)\) of the lowest-scoring features at each step, refits PLS, and tracks the CV-RMSE of the shrinking subset. The subset with the lowest recorded CV-RMSE across the whole shaving trajectory is returned.
Compared to backward variable elimination (BVE — see next), shaving removes a batch of features per step instead of one, which is faster (\(O(\log p)\) steps vs \(O(p)\)) but more aggressive — a single bad shave removes many useful features irrecoverably. Recommended \(\rho \le 0.2\) to keep shave granularity reasonable.
Appropriate uses¶
Backward elimination of low-importance wavelengths to trace a nested sequence of compact PLS models.
Limits and validation¶
Removed variables cannot re-enter and correlated importance rankings are unstable; subset choice can overfit CV.
Implementation¶
n4m_feature_selection_shaving_select.
Sources and provenance¶
Current implementation: cpp/src/core/shaving_selection.cpp.
API and bindings¶
C ABI (ABI 2): n4m_feature_selection_shaving_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 Shaving
Source signature: Shaving(*, n_components: int = 2, n_steps: int = 10, min_features: int | None = None, shave_fraction: float = 0.2, n_folds: int = 3) (n4m/_impl/selection.py).
R (source-verified): shaving_select(X, Y, n_components, n_steps = 10L, min_features = 5L, shave_fraction = 0.1).
The source signature has additional required inputs, so no example call is fabricated.
MATLAB / Octave (source-verified): shaving_select(X, Y, n_components, n_steps, min_features, shave_fraction).
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::shaving(method='SR')— iterative SR-shaving of low-importance features. Uses the sameset.seed(11)as the pls4all wrapper so the CV fold assignments coincide.
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 | 1.0 s |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ J 1.00 | 440.9 ms |
pls4all.sklearn | ⇄ J 0.50 | 2.32 ms🏆 |
| R · archived pls4all benchmark | ||
pls4all.R | ⇄ J 0.50 | 5.59 ms |
pls4all.R.formula | ⇄ J 0.50 | 7.94 ms |
pls4all.R.mdatools | ⇄ J 0.50 | 6.31 ms |
pls4all.R.pls | ⇄ J 0.50 | 6.29 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 38.2 ms |
| Backend | Parity | 200×40 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ J 1.00 | 424.1 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ J 1.00 | 445.2 ms |
pls4all.sklearn | ⇄ J 0.50 | 2.24 ms🏆 |
| R · archived pls4all benchmark | ||
pls4all.R | ⇄ J 0.50 | 5.24 ms |
pls4all.R.formula | ⇄ J 0.50 | 5.90 ms |
pls4all.R.mdatools | ⇄ J 0.50 | 6.06 ms |
pls4all.R.pls | ⇄ J 0.50 | 5.99 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 94.0 ms |
| Backend | Parity | 200×40 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ✓ J 1.00 | 454.0 ms |
| Python · archived pls4all benchmark | ||
pls4all.python | ✓ J 1.00 | 443.2 ms |
pls4all.sklearn | ⇄ J 0.50 | 2.26 ms🏆 |
| R · archived pls4all benchmark | ||
pls4all.R | ⇄ J 0.50 | 5.07 ms |
pls4all.R.formula | ⇄ J 0.50 | 5.85 ms |
pls4all.R.mdatools | ⇄ J 0.50 | 5.96 ms |
pls4all.R.pls | ⇄ J 0.50 | 5.97 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 35.1 ms |
See also: benchmark overview · methods index · interactive dashboard