-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/pattern change detection #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7001639
Implement adaptive change point detection algorithms (ADWIN, AV-CUSUM…
A-Aherbil 7f236a6
Implement adaptive change point detection algorithms (ADWIN, AV-CUSUM…
A-Aherbil 8135a9d
Clean up codebase: remove test files, unused modules, and inline comm…
A-Aherbil 7c197bf
Cleanup
A-Aherbil 59000b8
solve merge conflicts
A-Aherbil 1062ef7
Clean up and fix minor issues
A-Aherbil d1b5c2c
Fix tests and refactor shared resources for change point detection
ddee68d
Update documentation with correct usage examples and fix contributor …
f7d017b
Move GUI to ftio/gui/ and add script entry in pyproject.toml
dc5fad0
Update documentation with ftio_gui command
ed7b682
solved merge conflict
b8e883c
Refactoring
cd065aa
fix bug: add missing change point fields causing KeyError in socket l…
7f72d67
Merge branch 'development' into feature/pattern_change_detection
A-Tarraf 1af4f84
fixed unused code and formating
A-Tarraf 0e431df
fixed unused code and formating 2
A-Tarraf 038ac00
add --gui flag, fix documentation, and fix change point display bug
25f2145
fix import sorting and update documentation examples
7630e42
fix black formatting
4d7dbd3
fix merged cosine view and remove unused auto-update button
61b156a
fix dense merged view by normalizing each prediction to 5 wave cycles
28c092c
remove unused State import
055cf96
fix black formatting
89c99c0
add call tree for change point detection and GUI integration
45ea05b
docs: clarify pure vs hybrid mode for change point detection
86d8705
Add docstrings to SocketLogger and SocketListener classes
aee0417
Add docstrings to SocketLogger and SocketListener classes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,7 +116,7 @@ test: | |
|
|
||
| check_style: check_tools | ||
| black . | ||
| isort . | ||
| ruff check --fix | ||
| # flake8 . | ||
|
|
||
| check_tools: | ||
|
|
||
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
A-Aherbil marked this conversation as resolved.
Show resolved
Hide resolved
A-Aherbil marked this conversation as resolved.
Show resolved
Hide resolved
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,189 @@ | ||
| # Change Point Detection for Online I/O Pattern Analysis | ||
|
|
||
| This document describes the adaptive change point detection feature for FTIO's online predictor, which enables automatic detection of I/O pattern changes during streaming analysis. | ||
|
|
||
| ## Overview | ||
|
|
||
| Change point detection allows FTIO to automatically detect when the I/O pattern changes during online prediction. When a change is detected, the analysis window is adapted to focus on the new pattern, improving prediction accuracy. | ||
|
|
||
| Three algorithms are available: | ||
| - **ADWIN** (Adaptive Windowing) - Default | ||
| - **CUSUM** (Cumulative Sum) | ||
| - **Page-Hinkley** (Sequential change detection) | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Command Line | ||
|
|
||
| There are two configuration modes: | ||
|
|
||
| **Pure change point detection**: | ||
| ```bash | ||
| # Only change point detection, no hit-based optimization | ||
| predictor X.jsonl -e no -f 100 --online_adaptation adwin | ||
| predictor X.jsonl -e no -f 100 --online_adaptation cusum | ||
| predictor X.jsonl -e no -f 100 --online_adaptation ph | ||
| ``` | ||
|
|
||
| **Hybrid mode**: | ||
| ```bash | ||
| # Change point detection + hit-based optimization | ||
| predictor X.jsonl -e no -f 100 -w frequency_hits --online_adaptation adwin | ||
| predictor X.jsonl -e no -f 100 -w frequency_hits --online_adaptation cusum | ||
| predictor X.jsonl -e no -f 100 -w frequency_hits --online_adaptation ph | ||
| ``` | ||
|
|
||
| ### Configuration Modes Explained | ||
|
|
||
| | Mode | Flags | | ||
| |------|-------| | ||
| | Pure | `--online_adaptation <algo>` | | ||
| | Hybrid | `-w frequency_hits --online_adaptation <algo>` | | ||
|
|
||
| In **hybrid mode**, the two mechanisms are complementary: | ||
| - **Change point detection** handles pattern transitions (primary mechanism) | ||
| - **Hit-based** optimizes stable periods by shrinking the window (secondary optimization) | ||
|
|
||
| Hit-based only activates when change point detection reports no change. They do not interfere with each other. | ||
|
|
||
| ## Algorithms | ||
|
|
||
| ### ADWIN (Adaptive Windowing) | ||
|
|
||
| ADWIN uses Hoeffding bounds to detect statistically significant changes in the frequency distribution. | ||
|
|
||
| **How it works:** | ||
| 1. Maintains a sliding window of frequency observations | ||
| 2. Tests all possible cut points in the window | ||
| 3. Uses Hoeffding inequality to determine if the means differ significantly | ||
| 4. When change detected, discards old data and adapts window | ||
|
|
||
| **Parameters:** | ||
| - `delta` (default: 0.05): Confidence parameter. Lower values = higher confidence required for detection | ||
|
|
||
|
|
||
| ### AV-CUSUM (Adaptive-Variance Cumulative Sum) | ||
|
|
||
| CUSUM tracks cumulative deviations from a reference value, with adaptive thresholds based on data variance. | ||
|
|
||
| **How it works:** | ||
| 1. Establishes reference frequency from initial observations | ||
| 2. Calculates positive and negative cumulative sums: `S+ = max(0, S+ + x - μ - k)` and `S- = max(0, S- - x + μ - k)` | ||
| 3. Detects change when cumulative sum exceeds adaptive threshold (2σ) | ||
| 4. Drift parameter (k = 0.5σ) prevents small fluctuations from accumulating | ||
|
|
||
| **Parameters:** | ||
| - `window_size` (default: 50): Size of rolling window for variance calculation | ||
|
|
||
|
|
||
| ### STPH (Self-Tuning Page-Hinkley) | ||
|
|
||
| Page-Hinkley uses a running mean as reference and detects when observations deviate significantly. | ||
|
|
||
| **How it works:** | ||
| 1. Maintains running mean as reference | ||
| 2. Tracks cumulative positive and negative differences from reference | ||
| 3. Uses adaptive threshold and delta based on rolling standard deviation | ||
| 4. Detects change when cumulative difference exceeds threshold | ||
|
|
||
| **Parameters:** | ||
| - `window_size` (default: 10): Size of rolling window for variance calculation | ||
|
|
||
|
|
||
| ## Window Adaptation | ||
|
|
||
| When a change point is detected: | ||
|
|
||
| 1. **Exact timestamp** of the change is recorded | ||
| 2. **Analysis window** is adapted to start from the change point | ||
| 3. **Safety bounds** ensure minimum window size (0.5-1.0 seconds) | ||
| 4. **Maximum lookback** limits window to prevent using stale data (10 seconds) | ||
|
|
||
| ``` | ||
| Before change detection: | ||
| |-------- old pattern --------|-- new pattern --| | ||
| ^ change point | ||
|
|
||
| After adaptation: | ||
| |-- new pattern --| | ||
| ^ analysis starts here | ||
| ``` | ||
|
|
||
| ## GUI Dashboard | ||
|
|
||
| A real-time visualization dashboard is available for monitoring predictions and change points. | ||
|
|
||
| ### Starting the Dashboard | ||
|
|
||
| ```bash | ||
| # Install GUI dependencies (if not already installed) | ||
| pip install -e .[gui] | ||
|
|
||
| # 1. Start the GUI dashboard first | ||
| ftio-gui | ||
|
|
||
| # 2. Then run predictor with --gui flag to forward data to the dashboard | ||
| # Pure mode: | ||
| predictor X.jsonl -e no -f 100 --online_adaptation adwin --gui | ||
| # Or hybrid mode: | ||
| predictor X.jsonl -e no -f 100 -w frequency_hits --online_adaptation adwin --gui | ||
| ``` | ||
|
|
||
| The dashboard runs on `http://localhost:8050` and displays: | ||
| - Frequency timeline with change point markers | ||
| - Continuous cosine wave visualization | ||
| - Statistics (total predictions, changes detected, current frequency) | ||
|
|
||
| ### Dashboard Features | ||
|
|
||
| - **Auto-updating**: Refreshes automatically as new predictions arrive | ||
| - **Change point markers**: Red vertical lines indicate detected changes | ||
| - **Frequency annotations**: Shows old → new frequency at each change | ||
| - **Gap visualization**: Displays periods with no detected frequency | ||
| - **Auto-connect**: The predictor automatically connects to the GUI when `--gui` flag is used | ||
|
|
||
|
|
||
|
|
||
| ### Algorithm Selection | ||
|
|
||
| Algorithm is selected via the `--online_adaptation` flag: | ||
|
|
||
| | Flag Value | Algorithm | Description | | ||
| |------------|-----------|-------------| | ||
| | `adwin` | ADWIN | Statistical guarantees with Hoeffding bounds | | ||
| | `cusum` | AV-CUSUM | Rapid detection with adaptive variance | | ||
| | `ph` | Page-Hinkley | Sequential detection with running mean | | ||
|
|
||
| ## Call Tree | ||
|
|
||
| ### Change Point Detection Call Tree | ||
| ``` | ||
| ftio/cli/predictor.py::main() | ||
| └── ftio/prediction/processes.py::predictor_with_processes() | ||
| └── ftio/prediction/online_analysis.py::ftio_process() | ||
| └── online_analysis.py::window_adaptation() | ||
| ├── online_analysis.py::get_change_detector() | ||
| │ ├── ftio/prediction/change_point_detection.py::ChangePointDetector() # ADWIN | ||
| │ ├── ftio/prediction/change_point_detection.py::CUSUMDetector() # CUSUM | ||
| │ └── ftio/prediction/change_point_detection.py::SelfTuningPageHinkleyDetector() # PH | ||
| └── change_point_detection.py::detect_pattern_change_adwin() # or _cusum() or _pagehinkley() | ||
| └── ChangePointDetector::add_prediction() | ||
| └── ChangePointDetector::_detect_change() | ||
| ``` | ||
|
|
||
| ### GUI Integration Call Tree | ||
| ``` | ||
| ftio/cli/predictor.py::main() | ||
| ├── ftio/prediction/online_analysis.py::init_socket_logger() | ||
| │ └── online_analysis.py::SocketLogger() | ||
| └── ftio/prediction/processes.py::predictor_with_processes() | ||
| └── ftio/prediction/online_analysis.py::ftio_process() | ||
| └── online_analysis.py::log_to_gui_and_console() | ||
| └── online_analysis.py::get_socket_logger() | ||
| └── SocketLogger::send_log() # Sends to ftio-gui dashboard | ||
|
|
||
| ftio/gui/dashboard.py::main() # ftio-gui command | ||
| └── FTIODashApp::run() | ||
| ├── ftio/gui/socket_listener.py::SocketListener() # Receives from predictor | ||
| └── FTIODashApp::_create_cosine_timeline_plot() # Renders merged view | ||
| ``` |
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
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
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
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
A-Tarraf marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """ | ||
| FTIO GUI Dashboard for real-time prediction visualization. | ||
|
|
||
| This module provides a Dash-based web dashboard for visualizing FTIO predictions | ||
| and change point detection results in real-time. | ||
|
|
||
| Author: Amine Aherbil | ||
| Copyright (c) 2025 TU Darmstadt, Germany | ||
| Date: January 2025 | ||
|
|
||
| Licensed under the BSD 3-Clause License. | ||
| For more information, see the LICENSE file in the project root: | ||
| https://github.com/tuda-parallel/FTIO/blob/main/LICENSE | ||
|
|
||
| Requires: pip install ftio-hpc[gui] | ||
| """ | ||
|
|
||
| __all__ = [ | ||
| "FTIODashApp", | ||
| "PredictionData", | ||
| "ChangePoint", | ||
| "PredictionDataStore", | ||
| "SocketListener", | ||
| ] | ||
|
|
||
|
|
||
| def __getattr__(name): | ||
| """Lazy import to avoid requiring dash unless actually used.""" | ||
| if name == "FTIODashApp": | ||
| from ftio.gui.dashboard import FTIODashApp | ||
|
|
||
| return FTIODashApp | ||
| elif name == "SocketListener": | ||
| from ftio.gui.socket_listener import SocketListener | ||
|
|
||
| return SocketListener | ||
| elif name in ("PredictionData", "ChangePoint", "PredictionDataStore"): | ||
| from ftio.gui import data_models | ||
|
|
||
| return getattr(data_models, name) | ||
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.