Spaces:
Sleeping
Sleeping
| # π 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 | |
| --- | |