Skip to content

Conversation

@roelofsc
Copy link
Contributor

@roelofsc roelofsc commented Dec 4, 2025

Summary

  • Reworks DataPreprocessor to a flexible, steps-based pipeline. This makes it easier to add new steps and data transformers to the framework.
  • Adds CounterDiffTransformer for robust counter-to-diff/rate conversion (resets, rollovers, gap masking).
  • Introduces generate_quickstart_config to create a ready-to-train config (and optional YAML dump).
  • Added the argument features_to_select to the ColumnSelector as alternative to features_to_exclude.
  • Added the argument features_to_clip to the DataClipper as alternative to features_to_exclude.
  • Updates README and docs (configuration guide, examples, docstring fixes) and fixes docs build workflow (pages.yaml).
  • Updates and bugfixes of the notebook Example - Hyperparameter Optimization.ipynb.

Changes

  • DataPreprocessor
    • New steps-based API: DataPreprocessor(steps: Optional[List[Dict]] = None, **legacy_params).
    • STEP_REGISTRY and NAME_ALIASES to add new pipelin steps easily, with the option to add user-friendly aliases.
    • Enforced ordering:
      • NaN-introducing steps (duplicate_to_nan, counter_diff_transformer),
      • column_selector + low_unique_value_filter,
      • other transforms (angle_transformer, …),
      • simple_imputer,
      • scaler (standard_scaler/minmax_scaler; default to StandardScaler if none provided).
    • Validations:
      • Single step definitions enforced for: angle_transformer, column_selector, low_unique_value_filter, simple_imputer and scaler.
      • Auto-assign unique step names when repeated or names collide.
    • Backwards compatibility:
      • Legacy params still supported (old behavior with added counter-diff option).
      • If steps and legacy params are both given, steps take precedence with a warning.

Example config:

train:
   ....
  data_preprocessor:
    steps:
      - name: column_selector
        params:
          max_nan_frac_per_col: 0.2
      - name: low_unique_value_filter
      - name: simple_imputer
      - name: standard_scaler
    ....
  • CounterDiffTransformer (new)

    • Transforms monotonic counters to per-sample increments or per-second rates.
    • Handles resets/rollovers (strategies: zero, rollover, nan, auto), small-negative tolerance, first-sample fill.
    • Optional data gap masking via time-delta threshold (factor of median dt or explicit seconds).
    • Requires DatetimeIndex when compute_rate=True or masking is enabled.
  • Quickstart config generator (new)

    • generate_quickstart_config(...) builds a minimal, valid config dict and can write YAML.
    • _build_preprocessor_steps(...) composes steps for DataPreprocessor.
    • _dump_yaml_if_requested(...) safely writes YAML to disk.
  • Documentation

    • README updated with a quickstart example and CLI mention.
    • New/expanded configuration guide (steps table, examples, defaults, migration notes).
    • Docstring prolems for sphinx-apidoc fixed
    • GitHub Pages generation workflow bug fixed.

roelofsc and others added 12 commits November 26, 2025 14:34
…ough the configuration file, by providing a steps specification instead of a long list of arguments. Extend DataPreprocessor tests with new steps parameter set up.

Also ensures the default values of the DataTransformer classes are the same as the defaults in the DataPreprocessor.
…and update tests and test_data (test configuration files) accordingly
… to complement `features_to_exclude`.

Update the basic configuration.
Fix Docstring in fault_detection_model.py and move initialization of models in fault_detection_result.py here.
Fix Docstring in arcana.py.
…aClipper features_to_exclude and features_to_clip)
@roelofsc roelofsc force-pushed the feature-counter-transformer branch from afe3981 to 8679818 Compare December 4, 2025 15:18
return x_

def inverse_transform(self, x: pd.DataFrame) -> pd.DataFrame:
"""No-op inverse transformation. Not defined for this class, returns the input as is.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be possible to define an inverse transformation by adding up the increments. Would inverse transform not be necessary for visualizing reconstructions and ARCANA-importances?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The counter resets and data gap masking loses information, which makes the simple sum of diffs inaccurate (but close?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a plotting function to plot those counter diffs/rates if needed: https://github.com/AEFDI/EnergyFaultDetector/blob/feature-counter-transformer/energy_fault_detector/utils/visualisation.py#L98

At some we probably should restructure the visualisation module to make it easiert to use... :)

chr39552 and others added 2 commits December 8, 2025 12:00
…counter diffs/rates if they are present in the reconstruction
@roelofsc roelofsc merged commit 56dddeb into develop Dec 16, 2025
1 check passed
@roelofsc roelofsc deleted the feature-counter-transformer branch December 16, 2025 12:44
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.

4 participants