Feature implementation sst#274
Merged
Merged
Conversation
…le. Add a valueError for n_components > min(n_samples-1, 2*n_features) and run some tests.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new domain-adaptation transformer, Spectral Space Transform (SST), to align target spectra to a source/reference domain using an SVD-based shared latent space approach, plus a comprehensive test suite to validate sklearn compatibility and expected behavior.
Changes:
- Implement
SpectralSpaceTransform(fit/transform) with optional identity behavior whenX_source=None. - Add extensive tests covering sklearn compliance, correctness snapshots, edge cases for
n_components, and Pipeline/GridSearchCV metadata routing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
chemotools/adaptation/_spectral_space_transform.py |
Introduces the SST transformer implementation, including parameter constraints, fitting logic, and the transformation formula. |
tests/adaptation/test_spectral_space_transform.py |
Adds sklearn compliance checks, numerical regression tests, edge-case validation, and metadata-routing integration tests for SST. |
Comments suppressed due to low confidence (1)
tests/adaptation/test_spectral_space_transform.py:258
- Typo in docstring: "rises ValueError" should be "raises ValueError".
"""Verifies n_components > 2*n_features rises ValueError."""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Why is this change needed?
Adds the Spectral Space Transform (SST) transformer to the
chemotools.adaptationmodule. SST is a linear domain adaptation method that aligns target spectral data
to a source (reference) domain via SVD of the concatenated source-target matrix.
This extends the adaptation module alongside the existing DS and PDS transformers.
Type of change
Description
Implementation of
SpectralSpaceTransformfollowing the method described in:What was added
SpectralSpaceTransformtransformer inchemotools/adaptation/_spectral_space_transform.pyfit,transform,fit_transform)X_source=NoneTests added
n_components