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 model
README.md: Project documentation
pm25_predict.py: Python script for inference (optional)
🚀 Usage
You can use this model with the following steps
import pandas as pd
import joblib
from huggingface_hub import hf_hub_download
Download the model
repo_id = "sanjibkuanr/pm25-pollution-predictor"
filename = "pm25_model.pkl"
model_path = hf_hub_download(repo_id=repo_id, filename=filename)
model = joblib.load(model_path)
Check model's expected feature names
expected_features = model.feature_names_in_
print("Model expects features:\n", expected_features)
Prepare only the required features for input
sample_input = pd.DataFrame([{
"dewp": -21,
"temp": -12,
"pres": 1020,
"iws": 2.0,
"is": 0,
"ir": 0,
"cbwd_NW": 1,
"cbwd_SE": 0,
"cbwd_cv": 0,
"no": 100
}])
Select only columns the model expects
sample_input = sample_input[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.