Arav Kekane December 2024
Weather forecasting system using machine learning to predict temperature from global weather observations. Dataset contains 113,618 observations from cities worldwide with 41 features.
Basic Assessment:
- Data cleaning and preprocessing
- Exploratory data analysis
- Temperature and precipitation visualizations
- Forecasting model with performance evaluation
Advanced Assessment:
- Anomaly detection using Isolation Forest
- Multiple forecasting models (Random Forest, Gradient Boosting)
- Ensemble model combining predictions
- Feature importance analysis (3 methods)
- Climate pattern analysis by region
- Environmental impact analysis (air quality correlations)
- Geographical pattern analysis (ANOVA)
Install required packages:
pip install numpy pandas matplotlib seaborn scikit-learn scipy
Download dataset from: https://www.kaggle.com/datasets/nelgiriyewithana/global-weather-repository
Place Global_Weather_Repository.csv in project directory.
python run.py
Results save to results/ folder.
analysis.py - Core functions and classes (DataCleaner, Forecaster, plotting) run.py - Main execution script requirements.txt - Package dependencies results/ - Output directory containing plots and metrics
Data Cleaning
Missing values handled with linear interpolation to preserve temporal structure. Outliers detected using IQR method (threshold k=3). Multivariate anomalies identified with Isolation Forest (contamination=0.05). Features scaled using RobustScaler for outlier resistance.
Exploratory Analysis
Calculated Pearson correlations between features. Identified 18 strong correlations (|r| > 0.7). Analyzed temperature distributions using histograms, box plots, and Q-Q plots for normality testing.
Machine Learning Models
Random Forest: Ensemble of 100 decision trees, max depth 10. Reduces overfitting through bootstrap aggregating.
Gradient Boosting: Sequential ensemble of 100 trees with learning rate 0.1. Each tree corrects errors from previous iterations.
Ensemble: Weighted combination of both models. Weights determined by inverse MSE.
Feature Importance
Three methods implemented:
- Random Forest importance (Gini-based impurity reduction)
- Permutation importance (performance drop from feature shuffling)
- Mutual Information (information-theoretic dependency measure)
Advanced Analysis
Climate patterns analyzed by country using ANOVA. Air quality correlations computed with weather variables. Geographic differences tested for statistical significance.
Model Performance:
- Random Forest: RMSE=0.00135, MAE=0.00039, R²=0.9999
- Gradient Boosting: RMSE=0.00158, MAE=0.00066, R²=0.9999
- Ensemble: RMSE=0.00137, MAE=0.00048, R²=0.9999
Key Findings:
- Temperature highly predictable from weather variables (R²≈1)
- Wind speed negatively correlated with air pollution (r=-0.099)
- Significant temperature differences across countries (F=546.44, p<0.001)
- 5% of observations flagged as anomalies
Data split: 80% training (90,894 samples), 20% testing (22,724 samples) Outlier detection: IQR method with k=3 Anomaly detection: Isolation Forest with 5% contamination Scaling: RobustScaler (median and IQR based) Missing values: Linear interpolation
Random Forest parameters:
- n_estimators: 100
- max_depth: 10
- random_state: 42
Gradient Boosting parameters:
- n_estimators: 100
- learning_rate: 0.1
- max_depth: 5
- random_state: 42
Ensemble weighting: Inverse MSE
- Random Forest: 57.8%
- Gradient Boosting: 42.2%
Evaluation metrics:
- RMSE: Root Mean Squared Error
- MAE: Mean Absolute Error
- R²: Coefficient of Determination
results/correlations.png - Feature correlation heatmap results/temperature.png - Temperature distribution analysis results/predictions.png - Model predictions vs actual values results/model_performance.csv - Performance metrics for all models results/feature_importance.csv - Feature importance scores results/location_analysis.csv - Climate statistics by country
Dataset: Global Weather Repository https://www.kaggle.com/datasets/nelgiriyewithana/global-weather-repository
Libraries: numpy, pandas, scikit-learn, matplotlib, seaborn, scipy