Add ScatterShift augmentation (forward EMSC model) - #296
Open
prabeshjoshi wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chemotools.augmentation.ScatterShift, a transformer that injects randommultiplicative scatter and a random polynomial baseline using the forward
Extended Multiplicative Scatter Correction (EMSC) model:
x_aug = m·x + Σ cᵢ·λⁱ.Why is this change needed?
AddNoise), a constant baseline(
BaselineShift), a scalar multiplicative factor (SpectrumScale), axis shifts,and peak broadening, but has no augmenter for multiplicative scatter combined
with a wavelength-dependent baseline: the dominant physical scatter signature
in NIR/vibrational spectra.
ScatterShiftfills that gap and is the forwardcounterpart of the existing
ExtendedMultiplicativeScatterCorrection: augmentwith
ScatterShift, correct with EMSC.Closes
Related issues
Type of change
What changed?
chemotools/augmentation/_scatter_shift.pyimplementingScatterShift.ScatterShiftinchemotools/augmentation/__init__.py(import +__all__).tests/augmentation/test_scatter_shift.py.What did NOT change?
chemotools.scatter(EMSC/MSC correctors are unchanged).API and compatibility impact
Notes
ScatterShiftinheritsDocLinkMixin, TransformerMixin, OneToOneFeatureMixin, BaseEstimator, uses_parameter_constraintsfor all four parameters, and passescheck_estimator()at default parameters (identity transform whenmultiplicative_scale=0.0andadditive_scale=0.0).chemotools.augmentation(new classScatterShift);chemotools/augmentation/__init__.py(new export).public API modified.
Validation
Validation notes
task) viaruff format --check,ruff check, andpython -m pytest tests/augmentation/test_scatter_shift.py -v: all passing,6/6 tests, no lint or format issues. Have not yet run the full
task check/task test:matrixsuite; deferring to CI for the dependency-floor andmulti-version matrix.
Tests
Test coverage details
tests/augmentation/test_scatter_shift.pycase (
order=0), polynomial-baseline case (order≥1), reproducibility under afixed
random_state, and an explicit check that the internal polynomial basisis identical to
ExtendedMultiplicativeScatterCorrection's design matrix.check_estimator()compliance;round-trip sanity (augmenting then EMSC-correcting recovers the original signal),
checked manually, not asserted as a formal test.
Documentation
Documentation notes
ScatterShifthas a full numpydoc docstring (model equation, EMSCcross-reference, Afseth & Kohler 2012 reference, runnable example), but the
augmentation methods page (
methods/augmentation_methods.html) is not yetupdated. Happy to add an entry if you point me to the right file/format.
Dependency / build / CI impact
Reviewer focus
Please focus on:
the right approach, versus a different parameterization.
Checklist