This project is a data-driven anomaly detection tool.
This project takes energy data from CSV files, detects anomalies based on power generation patterns, visualizes them using interactive graphs, and generates summaries and insights. This tool aims to aid in identifying anomalies in power generation systems.
- Upload and analyze CSV files containing hourly power generation data
- Automatically detect anomalies using custom logic and thresholds
- Generate a visual graph with marked anomaly points
- Display a summary report with counts and severity breakdowns
- Save detected anomalies to a CSV file (
alerts_today.csv) - Support for multiple CSV files as separate workflows
- Account creation with saved CSV files
your-project/
|
├── src/ # Core application code
│ ├── app.py # Flask app and anomaly logic
│ ├── extensions.py # Database and login initialization for code
│ ├── forms.py # Handles login + register
│ ├── init_db.py # Database initialization for repo
│ ├── model.py # Anomaly detection + summary generation
│ ├── utils.py # Helpful functions for processing
│ ├── templates/
│ │ ├── home.html # Home page HTML template
│ │ ├── dashboard.html # Dashboard page HTML template
│ │ ├── login.html # Login page HTML template
│ │ ├── register.html # Register page HTML template
│ │ └── sidebar.html # Partial HTML for sidebar shared across pages
│ └── static/ # CSS, JS, images (e.g., sidebar.js)
│
├── Test CSVs/ # Sample datasets for testing/demo
├── .env # Secret keys and environment variables
├── .gitignore
├── alerts_today.csv # Automatically generated alerts file
├── requirements.txt # Python dependencies
└── README.md # You are here
The Test CSVs/ folder contains sample energy files you can use to:
- Simulate real-world uploads
- Validate anomaly detection logic
- See different edge cases and observe how the system responds
You can also modify these or supply your own CSVs in the same format:
date,generated_power_kw
2025-01-01 00:00:00, 33
2025-01-01 01:00:00, 33
...
Note: If a date is not provided by the CSV, time is automatically generated by the app, assuming one-hour increments starting on
2025-01-01 00:00
-
Clone the repo
git clone https://github.com/CorgiStrike/Energy-Anomaly-Detection.git cd Energy-Anomaly-Detection -
Set up a virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Create a
.envfile
See below. -
Create a database file
See below. -
Run the app
cd src python app.py
Then, visit http://localhost:5000 in your browser.
- In your project root, create your
.envfiletouch .env
- Open the
.envfile in your editor and add your variables in this format:SECRET_KEY=your-super-secret-key OPENAI_API_KEY=your-openai-api-key (not currrently used)
-
Run the
init_db.pyscriptcd src python init_db.py -
Wait for conformation that the database was created
Database initialized.
Watch the video walkthrough here
- OpenAI integration for detailed summaries
- Google Drive Syncing for automatic Zapier alerts
- Dropdown on dashboard to allow users to pick what statistic they want for their graph
This project is licensed under the terms of the MIT license. See the LICENSE file for details.