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_pls4all path mirrors the same R call with seed=11, giving bit-exact mask parity. The C++ step-count trajectory kernel is opt-in via legacy=True.

Parameters

Name

Type

Default

Notes

n_components

int

2

current public binding signature

n_steps

int

10

current public binding signature

min_features

int | None

None

current public binding signature

shave_fraction

float

0.2

current public binding signature

n_folds

int

3

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) — plsVarSel 0.10.0 · strict (rmse_rel ≤ 1e-06) — R plsVarSel::shaving(method='SR') — iterative SR-shaving of low-importance features. Uses the same set.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.

BackendParity200×40 (ms)
C++ native · libn4m
pls4all.cpp.blas+omp✓ J 1.001.0 s
Python · archived pls4all benchmark
pls4all.python✓ J 1.00440.9 ms
pls4all.sklearn⇄ J 0.502.32 ms🏆
R · archived pls4all benchmark
pls4all.R⇄ J 0.505.59 ms
pls4all.R.formula⇄ J 0.507.94 ms
pls4all.R.mdatools⇄ J 0.506.31 ms
pls4all.R.pls⇄ J 0.506.29 ms
R · external
📐ref.r_plsvarselsource38.2 ms
BackendParity200×40 (ms)
C++ native · libn4m
pls4all.cpp.blas+omp✓ J 1.00424.1 ms
Python · archived pls4all benchmark
pls4all.python✓ J 1.00445.2 ms
pls4all.sklearn⇄ J 0.502.24 ms🏆
R · archived pls4all benchmark
pls4all.R⇄ J 0.505.24 ms
pls4all.R.formula⇄ J 0.505.90 ms
pls4all.R.mdatools⇄ J 0.506.06 ms
pls4all.R.pls⇄ J 0.505.99 ms
R · external
📐ref.r_plsvarselsource94.0 ms
BackendParity200×40 (ms)
C++ native · libn4m
pls4all.cpp.blas+omp✓ J 1.00454.0 ms
Python · archived pls4all benchmark
pls4all.python✓ J 1.00443.2 ms
pls4all.sklearn⇄ J 0.502.26 ms🏆
R · archived pls4all benchmark
pls4all.R⇄ J 0.505.07 ms
pls4all.R.formula⇄ J 0.505.85 ms
pls4all.R.mdatools⇄ J 0.505.96 ms
pls4all.R.pls⇄ J 0.505.97 ms
R · external
📐ref.r_plsvarselsource35.1 ms

See also: benchmark overview · methods index · interactive dashboard