Documentation

Installation Guide

Mumbai AQI Prediction System — Real-Time Air Quality Forecasting Using XGBoost and Live Weather Data

Step-by-step Setup Verified Instructions Chat Support
Back to Project
Complete Guide

Installation Guide

Follow 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.

Step 1 — Extract and Navigate

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"

Step 2 — Create a Virtual Environment

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

Step 3 — Install Dependencies

pip install -r requirements.txt

This installs Django, XGBoost, scikit-learn, pandas, numpy, joblib, and all other required packages.

Step 4 — Get a Windy API Key

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.

Step 5 — Configure Environment Variables

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

Step 6 — Train the ML Model

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.pkl
  • scaler.pkl
  • feature_columns.pkl

Step 7 — Copy Model Files into Django Project

cp ../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/.

Step 8 — Run Database Migrations

python manage.py migrate

This creates the SQLite database and sets up the StationData and AQIPrediction tables.

Step 9 — Load Station Data (Optional)

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.

Step 10 — Start the Development Server

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.

Step 11 — Run Tests (Optional)

python manage.py test predictor

This runs the unit tests for models, views, and ML utilities.

Need Help Setting Up?

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.

Need Help?

Our team is here to assist you with installation and setup.

Chat with Us
Chat with us