This project is a machine learning weather prediction system built using Python, Scikit-Learn, and Streamlit.
The model predicts the temperature (°C) using weather-related features such as humidity, wind speed, visibility, pressure, and precipitation type.
The pipeline includes:
- Data preprocessing
- Feature engineering
- Linear Regression model training
- Temperature prediction script
- Interactive Streamlit Web App
- Temperature Prediction using Linear Regression
- Preprocessing Pipeline (scaling, encoding, handling missing values)
- Time Feature Extraction (year, month, day, hour, day of week)
- Model Evaluation (MAE, RMSE, R²)
- Streamlit Web App for real-time predictions
- Modular Codebase (clean structure for training & inference)
- Language: Python
- ML Framework: Scikit-Learn
- Web App: Streamlit
- Data Handling: pandas, NumPy
- Model Saving: joblib
Weather_Prediction/
│
├── data/
│ └── weatherHistory.csv
│
├── models/
│ └── weather_model.joblib
│
├── src/
│ ├── __init__.py
│ ├── preprocess.py
│ ├── train_model.py
│ ├── predict_example.py
│ └── app.py
│
├── requirements.txt
└── README.md
After training on the provided dataset:
- MAE: ~0.74°C
- RMSE: ~0.95°C
- R² Score: ~0.99
- Apparent Temperature
- Humidity
- Wind Speed
- Wind Bearing
- Visibility
- Pressure
- Precipitation Type
- Derived Date-Time Features (year, month, day, hour, dayofweek)
- Predicted Temperature (°C)
- Clone the repository:
git clone https://github.com/DulinaSamarathunga/Weather-Prediction-Model.git
cd Weather-Prediction-Model- Install dependencies:
pip install -r requirements.txtpython src/train_model.pyThis trains the Linear Regression model and saves it to:
models/weather_model.joblib
python src/predict_example.pyExample output:
Predicted Temperature (C): 22.65
streamlit run src/app.pyApp will open at:
http://localhost:8501
- Python 3.12+
- pandas
- numpy
- scikit-learn
- joblib
- streamlit
- Add Random Forest or XGBoost models
- Deploy Streamlit app online
- Improve UI with charts
- Add a REST API endpoint
Dulina Samarathunga
GitHub: https://github.com/DulinaSamarathunga