Skip to content

AirQ-TPOT is a FastAPI app that predicts Air Quality Index (PM) using a TPOT model with features Tm, T, SLP, VV and TM. It offers a responsive web interface and API, with the model saved as tpot_model.pkl.

Notifications You must be signed in to change notification settings

jarif87/tpot-driven-air-quality-modeling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tpot Driven Air Quality Modeling App

This project is a FastAPI web application that predicts the Air Quality Index (PM) based on environmental features using a machine learning model trained with TPOT (Tree-based Pipeline Optimization Tool). The app provides a user-friendly web interface and an API endpoint for predicting PM values from input features: Average Annual Minimum Temperature (Tm), Average Annual Temperature (T), Sea Level Pressure (SLP), Visibility (VV), and Average Annual Maximum Temperature (TM).

Project Overview

The application uses a TPOTRegressor model trained on a dataset of environmental variables to predict the Air Quality Index (PM). The model was optimized using Repeated K-Fold cross-validation and saved using Python's pickle module. The web interface is designed with a modern, responsive, and eye-catching blue-green theme, reflecting environmental concerns.

Features

  • Web Interface: A form to input Tm, T, SLP, VV, and TM and display the predicted PM.
  • API Endpoint: A RESTful API for programmatic predictions.
  • Responsive Design: Mobile-friendly UI with a clean, environmental-themed style.
  • Model: Optimized TPOT pipeline saved as tpot_model.pkl.

Dataset

The model was trained on a dataset with the following features:

  • Tm: Average annual minimum temperature (°C)
  • T: Average annual temperature (°C)
  • SLP: Sea level pressure (hPa)
  • VV: Visibility (km)
  • TM: Average annual maximum temperature (°C)
  • PM: Air Quality Index (target variable, µg/m³)

Sample Data (for demonstration; actual dataset may be larger):

+-----+------+---------+-----+------+------------+
| Tm  | T    | SLP     | VV  | TM   | PM         |
+-----+------+---------+-----+------+------------+
| 4.8 | 7.4  | 1017.6  | 0.5 | 9.8  | 219.720833 |
| 4.4 | 7.8  | 1018.5  | 0.6 | 12.7 | 182.1875   |
| 2.4 | 6.7  | 1019.4  | 0.6 | 13.4 | 154.0375   |
| 3.3 | 8.6  | 1018.7  | 0.8 | 15.5 | 223.208333 |
| 4.4 | 12.4 | 1017.3  | 1.3 | 20.9 | 200.645833 |
+-----+------+---------+-----+------+------------+

Project Structure

air-quality-app/
├── main.py                 # FastAPI application
├── tpot_model.pkl          # Trained TPOT model
├── templates/
│   └── index.html          # HTML form for predictions
├── static/
│   └── style.css           # CSS for styling the web interface
├── requirements.txt        # Python dependencies

Installation

Prerequisites

  • Python 3.7+
  • Git
  • A web browser for the interface
  • Optional: A cloud platform account (e.g., Render, Heroku) for deployment

Setup

  1. Clone the Repository:
    git clone https://github.com/jarif87/tpot-driven-air-quality-modeling.git
    cd tpot-driven-air-quality-modeling
    
  2. Create a Virtual Environment (recommended):
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install Dependencies:
pip install -r requirements.txt
  1. Contents of requirements.txt:
fastapi==0.115.13
Jinja2==3.1.6
numpy==1.26.4
pydantic==2.11.7
pandas==2.2.3
uvicorn==0.34.3
scikit-learn==1.2.2
python-multipart

Running Locally

uvicorn main:app

About

AirQ-TPOT is a FastAPI app that predicts Air Quality Index (PM) using a TPOT model with features Tm, T, SLP, VV and TM. It offers a responsive web interface and API, with the model saved as tpot_model.pkl.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages