Add time series signals and configurable shadow model sampling[working]#368
Open
Add time series signals and configurable shadow model sampling[working]#368
Conversation
- Add DTW and MSM signal classes for time series distance metrics
- Add msm.py utility for Move-Split-Merge distance calculation
- Add sample_shadow_indices() to AbstractInputHandler for custom sampling
- Add configurable sampling_method ('balanced'/'random') to shadow models
- Fix dataset params propagation using population.return_params()
- Add optimizer param filtering to prevent invalid argument errors
… into pr-c-core-module-changes
- Removed setting params to empty dict in get_dataloader() - Made better logic in get_dataset() such that if params is None we try to collect params from population. If we cant params is set to an empty dict to fit UserDataset().
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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
This PR adds two time series distance signals (DTW and MSM), introduces configurable shadow model sampling, and fixes several handler issues needed for time series MIA support.
New signals
DTW): Dynamic Time Warping distance between model output and target series. Requires optionalsktimedependency — raises a clearImportErrorif not installed.MSM): Move-Split-Merge distance, implemented from scratch inleakpro/signals/utils/msm.pywith no external dependencies.SIGNAL_REGISTRYand usable viasignal_namesin attack configs (e.g.multi_signal_lira).Configurable shadow model sampling
sampling_methodfield toShadowModelConfig(default:"balanced").create_shadow_models()now acceptssampling_method="balanced"(existing behavior) or"random"(delegates to handler for custom sampling logic).sample_shadow_indices()toAbstractInputHandleras an overrideable method — time series handlers (e.g.IndividualizedInputHandler) can override it to sample by individual rather than by record.Handler fixes
MIAHandler.get_dataset(): defaultparamsnow usespopulation.return_params()instead of{}, preserving dataset-specific settings (e.g. scaler, lookback) when recreating datasets for shadow model training.MIAHandler.get_optimizer(): usesinspect.signature()to filter out invalid optimizer kwargs before instantiation, preventing crashes when time series configs pass extra parameters.Bug fix
DotMapcompatibility bug inshadow_model_handler.pywheresampling_methodwould be read as an emptyDotMap()instead of defaulting to"balanced"when the key was absent from the config.Dependencies
sktimetomiaoptional deps anddevgroup inpyproject.toml.Tests
New test file
leakpro/tests/mia_attacks/utils/test_time_series_signals.py(18 tests):mv_msm_costandmv_msm_distanceImportErrorgracefully without sktimeSIGNAL_REGISTRYsample_shadow_indicesdefault returns correct count/subsetcreate_shadow_modelswithsampling_method="random"and invalid methodget_optimizer()filters invalid params and passes valid ones throughTest plan
balancedsampling