--- # 🌍 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 ---