Mumbai AQI Prediction System — Real-Time Air Quality Forecasting Using XGBoost and Live Weather Data
Back to ProjectFollow the steps below to set up the Mumbai AQI Prediction System on your local machine. The project runs on Python 3.10 and Django 5.x. You will need a free Windy API key for live weather functionality.
Extract the downloaded zip file. The main Django project is inside the mumbai_aqi/ subfolder. The Jupyter training notebook is in the root aqi project/ folder.
cd "aqi project/mumbai_aqi"
Create and activate a Python virtual environment to keep dependencies isolated.
python -m venv venv
# On Windows
venv\Scripts\activate
# On Mac or Linux
source venv/bin/activate
pip install -r requirements.txt
This installs Django, XGBoost, scikit-learn, pandas, numpy, joblib, and all other required packages.
Visit https://api.windy.com/keys and create a free account. When creating your key, select Point Forecast API. Copy the key — you will need it in the next step.
cp .env.example .env
Open the .env file in a text editor and fill in the following values:
WINDY_API_KEY=your_windy_api_key_here
SECRET_KEY=your_django_secret_key_here
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhost
Open mumbai_aqi_model.ipynb in Jupyter Notebook or JupyterLab from the root aqi project/ folder and run all cells. This trains the XGBoost model and saves three files into the models/ directory:
best_aqi_model.pklscaler.pklfeature_columns.pklcp ../models/best_aqi_model.pkl ml_models/
cp ../models/scaler.pkl ml_models/
cp ../models/feature_columns.pkl ml_models/
On Windows, use copy instead of cp, or drag the files manually into the ml_models/ folder inside mumbai_aqi/.
python manage.py migrate
This creates the SQLite database and sets up the StationData and AQIPrediction tables.
python manage.py load_station_data
This populates the StationData table from the included CSV file and enables the 90-day trend charts on the dashboard.
python manage.py runserver
Open your browser and go to http://127.0.0.1:8000. The dashboard should load with weather tiles and AQI trend charts.
python manage.py test predictor
This runs the unit tests for models, views, and ML utilities.
CodeAj offers a paid project setup session where our team walks you through the entire installation, explains the source code, and helps you prepare for your college viva. Visit codeaj.com for details or contact us through the marketplace listing.
Our team is here to assist you with installation and setup.