AQI_APP / README2.md
WebashalarForML's picture
Update README2.md
7eced5b verified
---
# 🌍 AQI Forecasting Web App with Map Visualization
This Flask-based web application allows users to input geographical coordinates (latitude and longitude) and receive air quality forecasts (AQI) for the next three days. It combines a deep learning model with real-time data from the Weatherbit API, and visualizes predictions on an interactive map using Folium.
---
## πŸš€ Features
- 🌐 **Interactive Map**: View AQI predictions across different locations.
- πŸ“‘ **Real-Time Data**: Integrates live air quality data from Weatherbit API.
- 🧠 **Deep Learning Model**: Predicts AQI for the next 3 days based on PM2.5, PM10, NO2, SO2, CO, and current AQI.
- πŸ“Š **Comparative Visualization**: Shows bar plots comparing model predictions and API forecasts.
- πŸ“ **CSV Logging**: Stores prediction data and actual AQI values from API into CSV files.
---
## πŸ› οΈ Setup Instructions
### 1. Clone the Repository
```bash
git clone https://github.com/your-username/aqi-forecast-app.git
cd aqi-forecast-app
```
### 2. Install Requirements
We recommend using a virtual environment.
```bash
pip install -r requirements.txt
```
### 3. Add Your API Key
Replace the `API_KEY` variable in `app.py` with your [Weatherbit API key](https://www.weatherbit.io/account/create).
```python
API_KEY = "your_api_key_here"
```
### 4. Add Model and Scalers
Ensure the following model and scaler files are in the project directory:
- `FUTURE_AQI_v1.json`
- `FUTURE_AQI_v1.weights.h5`
- `scaler_X_cpcb_4.pkl`
- `scaler_y_cpcb_4.pkl`
> These are required to load the trained model and scale inputs/outputs.
### 5. Run the App
```bash
python app.py
```
Visit [http://127.0.0.1:5000](http://127.0.0.1:5000) in your browser.
---
## πŸ“‚ File Structure
```
.
β”œβ”€β”€ app.py # Main Flask app
β”œβ”€β”€ FUTURE_AQI_v1.json # Model architecture
β”œβ”€β”€ FUTURE_AQI_v1.weights.h5 # Trained model weights
β”œβ”€β”€ scaler_X_cpcb_4.pkl # Scaler for input features
β”œβ”€β”€ scaler_y_cpcb_4.pkl # Scaler for output predictions
β”œβ”€β”€ aqi_data.csv # Stores model predictions
β”œβ”€β”€ aqi_data_actual_api.csv # Stores actual API forecast data
└── templates/
└── aqi_forecast_with_legend.html # HTML template
```
---
## πŸ“Š AQI Color Codes
The app uses the following colors for AQI categories:
| AQI Range | Color |
|----------------|--------------|
| 0–50 | Green |
| 51–100 | Light Green |
| 101–150 | Orange |
| 151–200 | Red |
| 201–300 | Purple |
| 301+ | Gray |
---
## πŸ“Œ Future Improvements
- πŸ“ Add support for historical AQI trends
- ⏳ Allow user-defined forecasting range
- πŸ“ˆ Deploy on cloud for public access
---