Skip to content

Add ScatterShift augmentation (forward EMSC model) - #296

Open
prabeshjoshi wants to merge 1 commit into
paucablop:mainfrom
prabeshjoshi:feat/scatter-shift
Open

Add ScatterShift augmentation (forward EMSC model)#296
prabeshjoshi wants to merge 1 commit into
paucablop:mainfrom
prabeshjoshi:feat/scatter-shift

Conversation

@prabeshjoshi

Copy link
Copy Markdown

Summary

  • Adds chemotools.augmentation.ScatterShift, a transformer that injects random
    multiplicative 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?

  • The augmentation module covers additive noise (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. ScatterShift fills that gap and is the forward
    counterpart of the existing ExtendedMultiplicativeScatterCorrection: augment
    with ScatterShift, correct with EMSC.

Closes

Related issues

Type of change

  • New feature
  • Tests only

What changed?

  • Added chemotools/augmentation/_scatter_shift.py implementing ScatterShift.
  • Registered ScatterShift in chemotools/augmentation/__init__.py (import + __all__).
  • Added tests/augmentation/test_scatter_shift.py.

What did NOT change?

  • No changes to chemotools.scatter (EMSC/MSC correctors are unchanged).
  • No changes to any other augmentation transformer.
  • No docs page updated yet (see Documentation notes below).

API and compatibility impact

  • Public API added

Notes

  • scikit-learn API compatibility: ScatterShift inherits DocLinkMixin, TransformerMixin, OneToOneFeatureMixin, BaseEstimator, uses
    _parameter_constraints for all four parameters, and passes
    check_estimator() at default parameters (identity transform when
    multiplicative_scale=0.0 and additive_scale=0.0).
  • Affected modules/classes/functions: chemotools.augmentation (new class
    ScatterShift); chemotools/augmentation/__init__.py (new export).
  • Backward compatibility considerations: purely additive change, no existing
    public API modified.

Validation

Validation notes

  • Verified locally (outside task) via ruff format --check, ruff check, and
    python -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:matrix suite; deferring to CI for the dependency-floor and
    multi-version matrix.

Tests

  • Added new tests

Test coverage details

  • Relevant test files: tests/augmentation/test_scatter_shift.py
  • Edge cases covered: identity behavior at default parameters, multiplicative-only
    case (order=0), polynomial-baseline case (order≥1), reproducibility under a
    fixed random_state, and an explicit check that the internal polynomial basis
    is identical to ExtendedMultiplicativeScatterCorrection's design matrix.
  • Numerical / estimator behavior checked: check_estimator() compliance;
    round-trip sanity (augmenting then EMSC-correcting recovers the original signal),
    checked manually, not asserted as a formal test.

Documentation

  • Docs updated
  • Docstrings updated

Documentation notes

  • ScatterShift has a full numpydoc docstring (model equation, EMSC
    cross-reference, Afseth & Kohler 2012 reference, runnable example), but the
    augmentation methods page (methods/augmentation_methods.html) is not yet
    updated. Happy to add an entry if you point me to the right file/format.

Dependency / build / CI impact

  • No dependency changes

Reviewer focus

Please focus on:

  • Whether the forward-model framing (and reuse of the EMSC polynomial basis) is
    the right approach, versus a different parameterization.

Checklist

  • I linked the relevant issue(s) or explained why none exists
  • I kept this PR scoped to a single purpose
  • I added or updated tests where appropriate
  • I updated documentation where appropriate
  • I verified the change locally using the relevant tasks above
  • I considered backward compatibility and public API impact
  • I am ready for review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: scatter augmentation via forward EMSC model

1 participant