sanjibkuanr/pm25-pollution-predictor
PM2.5 Air Pollution Prediction Model ๐ซ๏ธ
This project predicts the level of air pollution (PM2.5 concentration) using historical environmental data collected from Beijing between 2010 and 2014. It uses a machine learning model trained on weather and pollution-related features.
๐ Dataset
- Source: UCI Machine Learning Repository
- Data File:
PRSA_data_2010.1.1-2014.12.31.csv - Features Used:
- Temperature
- Dew Point
- Pressure
- Wind direction (CBWD)
- Cumulated wind speed (Iws)
- Cumulated hours of snow (Is)
- Cumulated hours of rain (Ir)
๐ง Model
- Type: Random Forest Regressor
- Framework: Scikit-learn
- Target Variable: PM2.5 concentration
- Evaluation: Rยฒ Score, Mean Squared Error (MSE)
๐ Files
pm25_model.pkl: Trained ML modelREADME.md: Project documentationpm25_predict.py: Python script for inference (optional)
๐ Usage
You can use this model with the following steps
import pandas as pd import joblib from huggingfacehub import hfhub_download
Download the model
repoid = "sanjibkuanr/pm25-pollution-predictor" filename = "pm25model.pkl" modelpath = hfhubdownload(repoid=repoid, filename=filename) model = joblib.load(modelpath)
Check model's expected feature names
expectedfeatures = model.featurenamesin print("Model expects features:\n", expected_features)
Prepare only the required features for input
sampleinput = pd.DataFrame([{ "dewp": -21, "temp": -12, "pres": 1020, "iws": 2.0, "is": 0, "ir": 0, "cbwdNW": 1, "cbwdSE": 0, "cbwdcv": 0, "no": 100 }])
Select only columns the model expects
sampleinput = sampleinput[expected_features]
Predict
prediction = model.predict(sample_input) print("Predicted PM2.5 level:", prediction[0])
Developed by Sanjib Kuanr as part of a Machine Learning learning initiative. Feel free to connect with me on LinkedIn! You are free to use, modify, and distribute.
