AI Power Outage Predictor for energy loss and gain in Nigeria
# AI Power Outage Predictor
A completely AI-powered system that predicts power outage probability using Random Forest machine learning. The system analyzes time patterns, day of week, location, and environmental factors to provide accurate outage predictions.
## Features
- **Fully AI-Powered**: Uses Random Forest classifier for intelligent predictions
- **Web Interface**: Beautiful, modern HTML homepage with interactive predictions
- **Feature Engineering**: Advanced time-based features (cyclic encoding, peak hours, seasons)
- **Location-Aware**: Supports multiple locations with location-specific patterns
- **Time-Based Analysis**: Considers hour of day, day of week, and seasonal patterns
- **Probability Output**: Provides percentage probability of power outage
- **Risk Assessment**: Categorizes risk levels (Low, Moderate, High, Very High)
## Technology Stack
- **Python 3.8+**
- **Flask**: Web framework for HTML interface
- **Pandas**: Data manipulation and analysis
- **Scikit-learn**: Random Forest machine learning model
- **NumPy**: Numerical computations
- **Joblib**: Model persistence
## Installation
1. Clone or download this repository
2. Install required packages:
```bash
pip install -r requirements.txt
```
## Quick Start
### Step 1: Generate Historical Data
Generate synthetic historical power outage data for training:
```bash
python data_generator.py
```
This creates `historical_outage_data.csv` with 365 days of hourly data.
### Step 2: Train the AI Model
Train the Random Forest model on the historical data:
```bash
python train_model.py
```
This will:
- Engineer features from raw data
- Train a Random Forest classifier
- Evaluate model performance
- Save the trained model as `power_outage_model.pkl`
### Step 3: Make Predictions
#### Option A: Web Interface (Recommended)
Start the web server:
```bash
python app.py
```
Then open your browser and navigate to:
```
localhost
```
You'll see a beautiful homepage where you ca …