t2_select — Hotelling T² loading selection¶
Group: Variable selector · Registry tolerance: 1.2
Description¶
T²-PLS loading-weight selection (§18 Phase 5l)
From the pls4all.sklearn.T2Selector docstring:
T²-PLS loading-weight selection (plsVarSel::T2_pls style).
Registry note — R
plsVarSel::T2_plsHotelling T² loading selection with train=test to match pls4all’s single-training-set selector. The remaining divergence is threshold semantics: plsVarSel chooses the$mv$min-error set across alpha levels, while pls4all thresholds training-score T² directly. Mask RMSE-rel ~0=perfect, ~1=half disagree, ~1.41=disjoint.
Parameters¶
Name |
Type |
Default |
Notes |
|---|---|---|---|
|
|
|
Sequence of significance levels (α) defining the T² acceptance regions to sweep. |
|
|
|
Number of latent components extracted (k). |
|
`int |
None` |
|
Explanations¶
Bibliographic source¶
Mehmood, T. (2016). Hotelling T² based variable selection in partial least squares regression. Chemometrics and Intelligent Laboratory Systems 154, 23–28. https://doi.org/10.1016/j.chemolab.2016.03.020 — proposes T²-PLS, the loading-weights-level Hotelling T² selector. See also Wold, Sjöström & Eriksson (2001), Chemometrics and Intelligent Laboratory Systems 58(2), 109–130 §6.2 for the original T²-vs-VIP discussion in PLS.
Mathematical principle¶
Apply Hotelling T² to the loading weights rather than the scores: features with loading vectors of large T² are deemed important. Threshold via the F-distribution upper control limit at a user-specified \(\alpha\), with a top-\(k\) fallback to avoid empty selections.
Distinct from sample-level T² monitoring (see pls_diagnostic_t2) — here T² acts as a multivariate feature ranker that respects correlation structure across components. Useful when the loadings have strong between-component structure and per-component VIP under-counts contributions spread across multiple components.
Implementation¶
n4m_t2_select.
MATLAB header (bindings/matlab/+pls4all/t2_select.m):
pls4all.t2_select T²-based selector (sweep over alpha thresholds).
Usage¶
Every pls4all binding tab dispatches into the same C kernel; the external libraries listed at the bottom of the page are the parity references registered in benchmarks.parity_timing.registry. Switch tabs to read the same fit in your language. The R package now ships drop-in-compatible facades for the CRAN pls package (plsr, pcr, mvr) and for the mdatools::pls(x, y, ...) matrix idiom — those tabs appear only on the methods that have a meaningful equivalence.
pls4all bindings
/* C ABI — libn4m */
n4m_context_t* ctx = n4m_context_create();
n4m_config_t* cfg = n4m_config_create();
n4m_method_result_t* res = NULL;
n4m_t2_select_fit(ctx, cfg, &x_view, &y_view, /* hyperparams */, &res);
/* … read coefficients / mask / scores via */
/* n4m_method_result_get_double_matrix / vector / scalar … */
n4m_method_result_destroy(res);
n4m_config_destroy(cfg);
n4m_context_destroy(ctx);
import pls4all
from pls4all._methods import t2_select_fit
with pls4all.Context() as ctx, pls4all.Config() as cfg:
res = t2_select_fit(ctx, cfg, X, y)
# then: res.matrix("predictions"), res.matrix("coefficients"),
# res.vector("mask"), res.scalar("intercept"), …
from pls4all.sklearn import T2Selector
mdl = T2Selector(alpha_thresholds, n_components=2, min_selected=None)
mdl.fit(X, y)
y_hat = mdl.predict(X_test)
library(pls4all)
# Unified low-level dispatcher (May 2026 R cleanup):
res <- pls4all_method("t2_select", X, y,
n_components = 2L)
# res is a named list with MethodResult arrays/scalars.
# selected_indices / top_k_intervals are 1-based.
res = pls4all.t2_select(X, y, 2);
% see header of bindings/matlab/+pls4all/t2_select.m for full
% parameter surface:
% res = t2_select(X, Y, n_components, alpha_thresholds, min_selected)
yhat = predict(res, Xtest);
No idiomatic classdef wrapper — invoke pls4all.fit("t2_select", X, y, …) directly from the unified MEX factory.
Registry parity references 📐
📐
ref.r_plsvarsel(R · r) —plsVarSel0.10.0 · qualitative (rmse_rel ≤ 1e+00) — RplsVarSel::T2_pls— Hotelling T² loading-weight selection. Same idea as pls4all’s T2_select.
Benchmarks¶
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 = pls4all binding 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: qualitative — shape/smoke comparison only. The external library and pls4all do not produce numerically equivalent output for this method (see the MethodSpec notes); the rmse_rel_tol ≤ 2e+00 budget is set wide on purpose. Treat ~ shape as “we ran both, both finished”, not as numerical agreement.
Rows tagged with 📐 are the canonical parity references for this method (declared in parity_timing.registry). C++ and external rows show reference parity; pls4all language bindings 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 0.80 | 1.67 ms🏆 |
| Python · pls4all | ||
pls4all.python | ✓ J 0.80 | 1.69 ms |
pls4all.sklearn | ✓ J 0.80 | 1.83 ms |
| R · pls4all | ||
pls4all.R | ✓ J 0.80 | 4.21 ms |
pls4all.R.formula | ✓ J 0.80 | 6.34 ms |
pls4all.R.mdatools | ✓ J 0.80 | 6.75 ms |
pls4all.R.pls | ✓ J 0.80 | 5.80 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 37.0 ms |
| Backend | Parity | 200×40 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ⇄ J 0.80 | 1.67 ms🏆 |
| Python · pls4all | ||
pls4all.python | ✓ J 0.80 | 1.69 ms |
pls4all.sklearn | ✓ J 0.80 | 1.89 ms |
| R · pls4all | ||
pls4all.R | ✓ J 0.80 | 5.03 ms |
pls4all.R.formula | ✓ J 0.80 | 5.50 ms |
pls4all.R.mdatools | ✓ J 0.80 | 5.35 ms |
pls4all.R.pls | ✓ J 0.80 | 5.34 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 35.9 ms |
| Backend | Parity | 200×40 (ms) |
|---|---|---|
| C++ native · libn4m | ||
pls4all.cpp.blas+omp | ⇄ J 0.80 | 1.66 ms🏆 |
| Python · pls4all | ||
pls4all.python | ✓ J 0.80 | 1.76 ms |
pls4all.sklearn | ✓ J 0.80 | 1.83 ms |
| R · pls4all | ||
pls4all.R | ✓ J 0.80 | 4.63 ms |
pls4all.R.formula | ✓ J 0.80 | 5.24 ms |
pls4all.R.mdatools | ✓ J 0.80 | 5.78 ms |
pls4all.R.pls | ✓ J 0.80 | 5.58 ms |
| R · external | ||
📐ref.r_plsvarsel | source | 35.4 ms |
See also: benchmark overview · methods index · interactive dashboard