This project is a Machine Learning solution engineered to predict rainfall in Nairobi, Kenya. It analyzes historical weather patterns to determine whether it will rain on a given day.
The model was built using Python and Scikit-Learn, leveraging weather data collected specifically for the Nairobi region from March 2024 to March 2025.
- Custom Classification Logic: Implemented Linear Regression with a custom decision boundary (threshold of 0.5) to convert continuous regression outputs into binary classification (Rain / No Rain).
- Feature Engineering: Processed key meteorological indicators including temperature, precipitation probability, wind speed, and humidity.
- High Accuracy: The model achieved a 90% accuracy rate on the test dataset.
- Language: Python 3.x
- Libraries: Scikit-Learn, Pandas, NumPy
- Data Processing: Custom preprocessing pipeline for continuous weather data.
The dataset consists of daily weather observations for Nairobi, Kenya, spanning a full annual cycle (March 2024 - March 2025).
Instead of using standard logistic regression, this project explores the utility of Linear Regression for classification tasks:
- Input: Continuous variables (Temperature, Wind Speed, Humidity, Precipitation Prob).
- Processing: Linear equation fitting.
-
Output Transformation: A threshold logic is applied where:
-
$y < 0.5 \rightarrow$ No Rain (0) -
$y \geq 0.5 \rightarrow$ Rain (1)
-
- Accuracy: 90%
- Context: The model successfully identified rain patterns during the distinct Nairobi rainy seasons within the dataset timeframe.
- Clone the repository:
git clone [https://github.com/gabrielnganga/Nairobi-Rainfall-Predictive-Classifier.git](https://github.com/gabrielnganga/Nairobi-Rainfall-Predictive-Classifier.git)
- Install dependencies:
pip install pandas scikit-learn numpy
- Run the predictor:
python main.py
Gabriel Ng'ang'a