pp_second_derivative — Second derivative¶
Group: Preprocessing · Binding: n4m.sklearn.SecondDerivative · C ABI: n4m_pp_second_derivative_*
Description¶
Two passes of np.gradient (shape-preserving).
Parameters¶
Name |
Type |
Default |
|---|---|---|
|
|
|
|
|
|
Explanations¶
Bibliographic source¶
Standard finite-difference / gap derivative; see Savitzky & Golay (1964) and Norris & Williams (1984).
Mathematical principle¶
Approximates \(\mathrm{d}^2\mathbf{x}/\mathrm{d}\lambda^2\). The second derivative removes both constant and linear baselines and resolves overlapping peaks into sharp negative lobes at the original band positions, at the cost of amplifying high-frequency noise (hence it is usually paired with smoothing).
Implementation¶
C ABI n4m_pp_second_derivative_* in libn4m (create / apply / destroy lifecycle), wrapped by n4m.sklearn.SecondDerivative. The same numerical kernel backs every language binding.
Usage¶
from n4m.sklearn import SecondDerivative
op = SecondDerivative()
X_transformed = op.fit_transform(X)
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: strict — numeric equivalence (rmse_rel_tol ≤ 1e-12).
| Backend | Parity | 50×250 (ms) | 250×50 (ms) |
|---|---|---|---|
| C++ native · libn4m | |||
pls4all.cpp.blas | ✓ ref | — | — |
pls4all.cpp.blas+omp | ✓ ref | 0.01 ms🏆 | 0.01 ms🏆 |
pls4all.cpp.omp | ✓ ref | — | — |
pls4all.cpp.ref | ✓ ref | 0.01 ms | 0.01 ms |
| Python · pls4all | |||
pls4all.python | ✓ bind | 0.02 ms | 0.02 ms |
pls4all.sklearn | ✓ bind | 0.02 ms | 0.02 ms |
| Python · external | |||
nirs4all | source | 0.07 ms | 0.08 ms |
ref.python_numpy | source | — | — |
See also: methods index · interactive dashboard