nirs4all.operators.models.sklearn.aom_pls module
AOM/POP-PLS public entry point backed by the native n4m engine.
- nirs4all.operators.models.sklearn.aom_pls.AOMPLSRegressor
alias of
NativeAOMPLSRegressor
- class nirs4all.operators.models.sklearn.aom_pls.ComposedOperator(operators: Sequence[LinearSpectralOperator], name: str | None = None)[source]
Bases:
LinearSpectralOperatorComposition of strict linear operators.
Given operators A_1, A_2, …, A_K, the composed operator is A = A_K @ … @ A_2 @ A_1. It is strictly linear in the input.
The convention is “apply leftmost first”: transform calls ops[0].transform, then ops[1].transform, etc., which corresponds to (((X A_1^T) A_2^T) … A_K^T) = X A_K^T … A_1^T = X (A_K … A_1)^T.
- fit(X: ndarray | None = None, y: ndarray | None = None) ComposedOperator[source]
Bind the operator to the feature dimensionality.
Strict-linear operators do not learn parameters from data; the only information they extract from X is its number of columns. Supervised operators may override fit to learn parameters; their prediction-time apply must remain linear in the input.
- class nirs4all.operators.models.sklearn.aom_pls.DetrendProjectionOperator(degree: int = 1, p: int | None = None)[source]
Bases:
LinearSpectralOperatorPolynomial detrend as the orthogonal projector onto the polynomial complement.
For a polynomial degree d, the basis matrix P in R^{p x (d+1)} spans {1, t, t^2, …, t^d} evaluated at evenly spaced points. The operator is the orthogonal projector onto the complement of range(P): A = I - Q Q^T where Q are the QR-orthonormal columns of P. Both the transform and the matrix are symmetric (A = A^T).
- class nirs4all.operators.models.sklearn.aom_pls.ExplicitMatrixOperator(matrix: ndarray, name: str = 'explicit')[source]
Bases:
LinearSpectralOperatorOperator backed by a fixed, externally provided matrix.
Used in tests to verify that the protocol holds for arbitrary linear maps.
- class nirs4all.operators.models.sklearn.aom_pls.FiniteDifferenceOperator(order: int = 1, p: int | None = None)[source]
Bases:
LinearSpectralOperatorFirst or second order centered finite difference.
- class nirs4all.operators.models.sklearn.aom_pls.IdentityOperator(p: int | None = None)[source]
Bases:
LinearSpectralOperatorThe identity operator. Always present in every default bank.
- class nirs4all.operators.models.sklearn.aom_pls.LinearSpectralOperator(name: str, p: int | None = None)[source]
Bases:
objectProtocol for strict linear spectral operators.
Subclasses implement at minimum _matrix_impl(p). Subclasses with cheap convolution implementations override _transform_impl, _apply_cov_impl, and _adjoint_vec_impl to avoid materializing the explicit p x p matrix.
- Variables:
- fit(X: ndarray | None = None, y: ndarray | None = None) LinearSpectralOperator[source]
Bind the operator to the feature dimensionality.
Strict-linear operators do not learn parameters from data; the only information they extract from X is its number of columns. Supervised operators may override fit to learn parameters; their prediction-time apply must remain linear in the input.
- class nirs4all.operators.models.sklearn.aom_pls.NorrisWilliamsOperator(gap: int = 5, smoothing: int = 5, order: int = 1, p: int | None = None)[source]
Bases:
LinearSpectralOperatorNorris-Williams gap derivative with optional moving-average smoothing.
The operator first applies a centered moving-average smoothing of length smoothing and then computes a gap derivative D x[i] = (x[i + g] - x[i - g]) / (2 g) (or the second-difference equivalent for order=2). The two stages compose into a single Toeplitz convolution; the result is strictly linear in the input.
- nirs4all.operators.models.sklearn.aom_pls.POPPLSRegressor
alias of
NativePOPPLSRegressor
- class nirs4all.operators.models.sklearn.aom_pls.SavitzkyGolayOperator(window_length: int = 11, polyorder: int = 2, deriv: int = 0, p: int | None = None)[source]
Bases:
LinearSpectralOperatorSavitzky-Golay smoothing or derivative as a strict linear operator.
Boundaries are zero-padded so that the operator is strictly linear in the input. This avoids data-dependent boundary modes which would otherwise couple samples through the operator.
- class nirs4all.operators.models.sklearn.aom_pls.WhittakerOperator(lam: float = 1000.0, p: int | None = None)[source]
Bases:
LinearSpectralOperatorWhittaker smoother as a strict linear operator.
The smoother solves (I + lam D^T D) z = x with D the (p-2) x p second-difference matrix. The matrix A = (I + lam D^T D)^{-1} is symmetric positive definite, so A^T = A. We pre-factorise the banded matrix once per feature dimensionality and apply the factor when needed.
- nirs4all.operators.models.sklearn.aom_pls.bank_by_name(name: str, p: int | None = None) List[LinearSpectralOperator][source]
Resolve a bank preset by name.
- nirs4all.operators.models.sklearn.aom_pls.compact_bank(p: int | None = None) List[LinearSpectralOperator][source]
Small, well-tested bank suitable for benchmark runs and smoke tests.
Contains identity, two SG smoothers, two SG first-derivatives, one SG second-derivative, two detrend projections, and two finite-difference operators. All entries are cheap, strictly linear, and zero-padded.
- nirs4all.operators.models.sklearn.aom_pls.default_bank(p: int | None = None) List[LinearSpectralOperator][source]
Default benchmark bank — exact 1:1 mirror of the production nirs4all default_operator_bank.
The bank has 100 operators:
1 identity (always first);
32 “savgol-family” entries: SG (deriv 0/1/2 across polyorder 2 and 3) + FD order 1/2 + 8 Norris-Williams variants;
3 detrend projections (degree 0, 1, 2);
64 composed operators (every savgol-family entry composed with detrend degree 0 and detrend degree 1).