This project is designed to predict weather patterns in African countries using historical weather data. The goal is to forecast temperatures based on various factors such as location, date, humidity, wind speed, and precipitation.
This project is designed to predict weather patterns in African countries using historical weather data. The goal is to forecast temperatures based on various factors such as location, date, humidity, wind speed, and precipitation. The project involves:
Preprocessing the dataset: Filtering, cleaning, and feature engineering.
Exploratory Data Analysis (EDA): Exploring temperature trends, weather conditions, and insights from various features.
Modeling: Training a Random Forest Regressor model to predict temperatures.
Evaluation: Using metrics like R-squared, Mean Squared Error (MSE), and Root Mean Squared Error (RMSE) to assess model performance.
Prediction Interface: Users can input a location and date to receive a temperature prediction.
Observation
Feature Engineering and Data Preparation
We removed columns that we deemed irrelevant for the prediction of temperature such as air quality, visibility, time-based features like sunrise/sunset, etc.
Remaining features are
Categorical: country, location_name, condition_text
Numerical: humidity, wind_kph, precip_mm, year, month, day
The target variable is temperature_celsius.
Date conversion: the last_updated column is converted to a datetime format, and new features like the year, month, and day are extracted.
Model Development
The categorical columns which are location_name, country and condition_text are one-hot encoded. This is necessary as machine learning models typically require numerical input, and one-hot encoding transforms categorical data into a binary matrix.
We used Random Forest Regressor, which is a robust model for regression tasks. Random forests typically perform well with diverse data and are less prone to overfitting, thus making it suitable for this kind of weather prediction task. Our model uses 100 estimators (n_estimators=100), and a random seed ensures reproducibility.
Evaluation Metrics
R-squared: The model has an R-squared value of 0.886, which is quite high. This indicates that the mode …