Refactor and clean up codebase: remove unused scripts, enhance behavi… - #2
Merged
Merged
Conversation
…oral features, and update model training pipeline - Deleted `serve_dashboard.py`, `check_status.py`, `simple_ingestion.py`, `start_system.py`, and `test_ingestion.py` as they are no longer needed. - Updated `behavioral_features.py` to include `Payment_currency` and `Received_currency` in partitioning for more accurate feature calculations. - Modified `baseline.py` to include `StandardScaler` in the logistic regression pipeline for better model performance. - Adjusted `train.py` to reflect changes in feature names and removed deprecated features. - Added tests in `test_leakage.py` to ensure no leakage occurs and that behavioral features are correctly calculated based on currency.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed inconsistencies/bugs (currency-aware refactor is incomplete for pair_transaction_count, and README Python version conflicts with pyproject.toml/CI) that should be resolved before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR refactors the repository from a legacy “real-time monitoring demo” into a research-oriented modeling pipeline, focusing on leakage-safe feature engineering, improved baseline modeling, and reproducibility/CI hygiene.
Changes:
- Removed legacy dashboard/API/ingestion launcher scripts and old notebooks; updated README to the new research/pipeline framing.
- Updated behavioral feature generation to be more currency-aware and adjusted model feature contracts accordingly.
- Improved the logistic baseline (scaling) and strengthened metadata/reproducibility (package versions, training windows, probability quantiles), plus added CI and leakage-related tests.
File summaries
| File | Description |
|---|---|
tests/test_leakage.py |
Adds tests for leakage-free behavioral features, currency awareness, and chronological split boundaries. |
start_system.py |
Deletes top-level legacy launcher script. |
src/utils/test_ingestion.py |
Deletes legacy ingestion test utility. |
src/utils/start_system.py |
Deletes legacy “start API + dashboard” orchestration script. |
src/utils/simple_ingestion.py |
Deletes demo transaction stream simulator. |
src/utils/check_status.py |
Deletes legacy status checker. |
src/models/train.py |
Updates model feature lists and retains chronological split helper. |
src/models/baseline.py |
Wraps SGD logistic baseline in a pipeline with StandardScaler. |
src/features/behavioral_features.py |
Updates rolling windows to partition by currency and refactors lifetime/network-related features + HHI logic. |
src/dashboard/serve_dashboard.py |
Deletes dashboard HTTP server. |
src/dashboard/real_time_dashboard.html |
Deletes legacy dashboard UI. |
src/api/simple_api_server.py |
Deletes legacy simple API server. |
scripts/train_model.py |
Improves artifact metadata (quantiles, time windows, prevalence, params, package versions). |
README.md |
Rewrites documentation for the research/pipeline focus and new API entrypoints. |
pyproject.toml |
Adds packaging/test/lint configuration and declares Python version requirement. |
notebooks/03_backtesting.ipynb |
Deletes legacy notebook. |
notebooks/02_model_research.ipynb |
Deletes legacy notebook. |
notebooks/01_eda.ipynb |
Deletes legacy notebook. |
docs/assets/.gitkeep |
Adds placeholder for documentation assets directory. |
.github/workflows/ci.yml |
Adds CI workflow to run tests on Python 3.11/3.12. |
Review details
Suppressed comments (1)
src/features/behavioral_features.py:109
pair_transaction_countis still partitioned only by(Sender_account, Receiver_account)while other rolling behavioral windows were updated to be currency-aware. This can mix interactions across currencies (e.g., USD and EUR transfers between the same pair) and makes the feature contract inconsistent with the currency-aware intent of this refactor.
COUNT(*) OVER (
PARTITION BY Sender_account, Receiver_account
ORDER BY timestamp
RANGE BETWEEN UNBOUNDED PRECEDING
AND INTERVAL '1 microsecond' PRECEDING
) AS pair_transaction_count
- Files reviewed: 19/20 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
…oral features, and update model training pipeline
serve_dashboard.py,check_status.py,simple_ingestion.py,start_system.py, andtest_ingestion.pyas they are no longer needed.behavioral_features.pyto includePayment_currencyandReceived_currencyin partitioning for more accurate feature calculations.baseline.pyto includeStandardScalerin the logistic regression pipeline for better model performance.train.pyto reflect changes in feature names and removed deprecated features.test_leakage.pyto ensure no leakage occurs and that behavioral features are correctly calculated based on currency.