Spaces:
Sleeping
Sleeping
File size: 2,842 Bytes
df265b9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
---
# π 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
---
|