How pranjal269/airqualityindex works
This repository is an AQI prediction workflow: it collects OpenAQ measurements, cleans and engineers them, analyzes patterns, trains location-specific models, generates predictions, and prepares Power BI data. The README documents the ordered workflow and capabilities; sampled scripts show key file reads and writes. The R analysis and Power BI dashboard are documented but their implementation internals were not sampled, so those links reflect README-described workflow rather than inspected calls.
Main entry points: 8_export_for_powerbi.py Power BI data export · ml_ready_data.csv Engineered dataset · 6_train_models.py Location model training · 7_generate_predictions.py AQI prediction generation
Components 19
Data collection
- API connection check
scripts/0_test_connection.py - Measurement fetcher
scripts/1_fetch_data.py - Raw measurements
data
Data preparation
- Data cleaning
scripts/2_preprocess_data.py - Cleaned measurements
data/processed/cleaned_data_final.csv - Data quality inspection
scripts/3_inspect_data.py - AQI and feature engineering
scripts/4_feature_engineering.py - Engineered dataset
data/processed/ml_ready_data.csv
Analysis and modeling
- Statistical analysis
scripts/5_statistical_analysis.R - Location model training
scripts/6_train_models.py - Trained model artifacts
models - Model performance metrics
models/model_metrics.csv
Prediction and dashboard
- AQI prediction generation
scripts/7_generate_predictions.py - Prediction results
data/predictions/predictions_all.csv - Power BI data export
scripts/8_export_for_powerbi.py - Power BI datasets
data/powerbi - Interactive dashboard
AQI_Dashboard.pbix
Other components
- Pipeline operator
- OpenAQ API
Connections 28
- Pipeline operator → API connection check: checks access
README.md - API connection check → OpenAQ API: tests API
scripts/0_test_connection.py - Pipeline operator → Measurement fetcher: runs collection
README.md - Measurement fetcher → OpenAQ API: fetches measurements
scripts/1_fetch_data.py - Measurement fetcher → Raw measurements: saves measurements
README.md - Pipeline operator → Data cleaning: runs cleaning
README.md - Data cleaning → Cleaned measurements: writes cleaned data
scripts/2_preprocess_data.py - Pipeline operator → Data quality inspection: runs validation
README.md - Raw measurements → Data quality inspection: inspects latest file
scripts/3_inspect_data.py - Pipeline operator → AQI and feature engineering: runs engineering
README.md - Cleaned measurements → AQI and feature engineering: loads cleaned data
README.md - AQI and feature engineering → Engineered dataset: writes engineered data
README.md - Pipeline operator → Statistical analysis: runs analysis
README.md - Cleaned measurements → Statistical analysis: analyzes measurements
- Pipeline operator → Location model training: runs training
README.md - Engineered dataset → Location model training: loads features
scripts/6_train_models.py - Location model training → Trained model artifacts: saves models
scripts/6_train_models.py - Location model training → Model performance metrics: writes metrics
scripts/6_train_models.py - Pipeline operator → AQI prediction generation: runs prediction
README.md - Engineered dataset → AQI prediction generation: loads features
scripts/7_generate_predictions.py - Trained model artifacts → AQI prediction generation: loads models
scripts/7_generate_predictions.py - AQI prediction generation → Prediction results: writes results
scripts/7_generate_predictions.py - Pipeline operator → Power BI data export: runs export
README.md - Prediction results → Power BI data export: formats predictions
scripts/8_export_for_powerbi.py - Engineered dataset → Power BI data export: reads location metadata
scripts/8_export_for_powerbi.py - Model performance metrics → Power BI data export: loads metrics
scripts/8_export_for_powerbi.py - Power BI data export → Power BI datasets: writes dashboard data
scripts/8_export_for_powerbi.py - Power BI datasets → Interactive dashboard: visualizes datasets
README.md