Skip to content

CorgiStrike/Energy-Anomaly-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Energy Anomaly Detection Program

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.

Features

  • 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

Project Structure

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

Test Data

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

Installation

  1. Clone the repo

    git clone https://github.com/CorgiStrike/Energy-Anomaly-Detection.git
    cd Energy-Anomaly-Detection
  2. Set up a virtual environment

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Create a.env file
    See below.

  5. Create a database file
    See below.

  6. Run the app

    cd src
    python app.py

Then, visit http://localhost:5000 in your browser.

Creating a .env file

  1. In your project root, create your .env file
    touch .env
  2. Open the .env file 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)

Creating a database file

  1. Run the init_db.py script

    cd src
    python init_db.py
  2. Wait for conformation that the database was created

    Database initialized.
    

Video Walkthrough

Watch the video walkthrough here

Future Plans

  • 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

License

This project is licensed under the terms of the MIT license. See the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors