Spaces:
Sleeping
Sleeping
Create README2.md
Browse files- README2.md +105 -0
README2.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# π AQI Forecasting Web App with Map Visualization
|
| 6 |
+
|
| 7 |
+
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.
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
## π Features
|
| 12 |
+
|
| 13 |
+
- π **Interactive Map**: View AQI predictions across different locations.
|
| 14 |
+
- π‘ **Real-Time Data**: Integrates live air quality data from Weatherbit API.
|
| 15 |
+
- π§ **Deep Learning Model**: Predicts AQI for the next 3 days based on PM2.5, PM10, NO2, SO2, CO, and current AQI.
|
| 16 |
+
- π **Comparative Visualization**: Shows bar plots comparing model predictions and API forecasts.
|
| 17 |
+
- π **CSV Logging**: Stores prediction data and actual AQI values from API into CSV files.
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## π οΈ Setup Instructions
|
| 22 |
+
|
| 23 |
+
### 1. Clone the Repository
|
| 24 |
+
|
| 25 |
+
```bash
|
| 26 |
+
git clone https://github.com/your-username/aqi-forecast-app.git
|
| 27 |
+
cd aqi-forecast-app
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### 2. Install Requirements
|
| 31 |
+
|
| 32 |
+
We recommend using a virtual environment.
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
pip install -r requirements.txt
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
### 3. Add Your API Key
|
| 39 |
+
|
| 40 |
+
Replace the `API_KEY` variable in `app.py` with your [Weatherbit API key](https://www.weatherbit.io/account/create).
|
| 41 |
+
|
| 42 |
+
```python
|
| 43 |
+
API_KEY = "your_api_key_here"
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### 4. Add Model and Scalers
|
| 47 |
+
|
| 48 |
+
Ensure the following model and scaler files are in the project directory:
|
| 49 |
+
|
| 50 |
+
- `FUTURE_AQI_v1.json`
|
| 51 |
+
- `FUTURE_AQI_v1.weights.h5`
|
| 52 |
+
- `scaler_X_cpcb_4.pkl`
|
| 53 |
+
- `scaler_y_cpcb_4.pkl`
|
| 54 |
+
|
| 55 |
+
> These are required to load the trained model and scale inputs/outputs.
|
| 56 |
+
|
| 57 |
+
### 5. Run the App
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
python app.py
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
Visit [http://127.0.0.1:5000](http://127.0.0.1:5000) in your browser.
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## π File Structure
|
| 68 |
+
|
| 69 |
+
```
|
| 70 |
+
.
|
| 71 |
+
βββ app.py # Main Flask app
|
| 72 |
+
βββ FUTURE_AQI_v1.json # Model architecture
|
| 73 |
+
βββ FUTURE_AQI_v1.weights.h5 # Trained model weights
|
| 74 |
+
βββ scaler_X_cpcb_4.pkl # Scaler for input features
|
| 75 |
+
βββ scaler_y_cpcb_4.pkl # Scaler for output predictions
|
| 76 |
+
βββ aqi_data.csv # Stores model predictions
|
| 77 |
+
βββ aqi_data_actual_api.csv # Stores actual API forecast data
|
| 78 |
+
βββ templates/
|
| 79 |
+
βββ aqi_forecast_with_legend.html # HTML template
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
---
|
| 83 |
+
|
| 84 |
+
## π AQI Color Codes
|
| 85 |
+
|
| 86 |
+
The app uses the following colors for AQI categories:
|
| 87 |
+
|
| 88 |
+
| AQI Range | Color |
|
| 89 |
+
|----------------|--------------|
|
| 90 |
+
| 0β50 | Green |
|
| 91 |
+
| 51β100 | Light Green |
|
| 92 |
+
| 101β150 | Orange |
|
| 93 |
+
| 151β200 | Red |
|
| 94 |
+
| 201β300 | Purple |
|
| 95 |
+
| 301+ | Gray |
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
|
| 99 |
+
## π Future Improvements
|
| 100 |
+
|
| 101 |
+
- π Add support for historical AQI trends
|
| 102 |
+
- β³ Allow user-defined forecasting range
|
| 103 |
+
- π Deploy on cloud for public access
|
| 104 |
+
|
| 105 |
+
---
|