🌧️ Haldwani Rainfall Nowcast & Forecast

A 5-model weighted ensemble for hourly rain prediction over Haldwani, Uttarakhand, India.
Built on open meteorological data from Open-Meteo, the system fuses Random Forest, Extra Trees, XGBoost, CatBoost, and LightGBM into a calibrated, uncertainty-aware forecast.


πŸ—‚οΈ Repository Contents

β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ random_forest.pkl          # Scikit-learn RandomForestClassifier
β”‚   β”œβ”€β”€ extra_trees.pkl            # Scikit-learn ExtraTreesClassifier
β”‚   β”œβ”€β”€ xgboost.pkl                # XGBoost XGBClassifier
β”‚   β”œβ”€β”€ catboost.pkl               # CatBoost CatBoostClassifier
β”‚   β”œβ”€β”€ lightgbm.pkl               # LightGBM LGBMClassifier
β”‚   β”œβ”€β”€ weighted_ensemble.pkl      # Full weighted fusion model
β”‚   β”œβ”€β”€ feature_columns.pkl        # Ordered list of input features
β”‚   β”œβ”€β”€ threshold.pkl              # Classification threshold (v1)
β”‚   β”œβ”€β”€ production_config.pkl      # Per-model weights + threshold
β”‚   β”œβ”€β”€ final_model_v2.pkl         # v2 single-model checkpoint
β”‚   β”œβ”€β”€ final_features_v2.pkl      # v2 feature columns
β”‚   └── final_threshold_v2.pkl     # v2 classification threshold
β”œβ”€β”€ app.py                         # Streamlit forecast dashboard
β”œβ”€β”€ predictor.py                   # RainPredictor inference class
β”œβ”€β”€ feature_engineering.py         # Feature construction pipeline
β”œβ”€β”€ weather_api.py                 # Open-Meteo API wrapper
β”œβ”€β”€ config.py                      # Path configuration
β”œβ”€β”€ requirements.txt               # Python dependencies
└── plots/                         # Diagnostic & analysis plots

🧠 Models

Model Type Library
Random Forest Bagging ensemble scikit-learn
Extra Trees Bagging ensemble scikit-learn
XGBoost Gradient boosting xgboost
CatBoost Gradient boosting catboost
LightGBM Gradient boosting lightgbm

All five models are combined into a weighted ensemble via production_config.pkl, which stores each model's weight and the optimal classification threshold.

Uncertainty Estimation

The ensemble computes the unweighted standard deviation across all 5 model probabilities per forecast step. High std = models disagree = high uncertainty. This is used in the app to blend AI probability with Open-Meteo's POP (Probability of Precipitation) signal.


βš™οΈ Inference

Load & predict

import joblib
import pandas as pd
from predictor import RainPredictor
from weather_api import get_forecast_by_city, get_recent_observed

# Load the predictor (loads all models + config internally)
predictor = RainPredictor()

# Fetch live data from Open-Meteo
history_df  = get_recent_observed("Haldwani")
forecast_df = get_forecast_by_city("Haldwani")

# Run inference
results = predictor.predict(history_df, forecast_df)
print(results[["time", "rain_probability", "prediction_label"]].head(24))

Output columns

Column Description
rain_probability Weighted ensemble probability (0–100)
prediction Binary prediction: 1 = Rain, 0 = No Rain
prediction_label "Rain" / "No Rain"
prob_random_forest Per-model probability (0–100)
prob_extra_trees Per-model probability (0–100)
prob_xgboost Per-model probability (0–100)
prob_catboost Per-model probability (0–100)
ensemble_std Model disagreement / uncertainty (0–100)

πŸš€ Run the Streamlit App

pip install -r requirements.txt
streamlit run app.py

The dashboard shows:

  • Hourly rain forecast for the next 24 h
  • Per-model probability breakdown
  • Uncertainty-aware fusion with Open-Meteo POP
  • Historical model diagnostics

πŸ“¦ Dependencies

streamlit==1.47.1
pandas==2.3.1
numpy==2.3.2
scikit-learn
joblib==1.5.1
requests==2.32.4
plotly==6.2.0
python-dateutil==2.9.0.post0
xgboost
catboost
lightgbm

πŸ“ Location

Haldwani, Uttarakhand, India
Lat: 29.2183Β° N, Lon: 79.5130Β° E
Timezone: Asia/Kolkata (IST, UTC+5:30)

Weather data sourced from Open-Meteo β€” free, no API key required.


πŸ“Š Diagnostics

Model evaluation plots are included under plots/:

  • Per-model diagnostic charts (confusion matrix, ROC, calibration)
  • Weighted ensemble vs fusion comparison
  • Feature importance comparison across models
  • Rolling accuracy, temporal F1, and weight sensitivity analysis

πŸ‘€ Author

Aditya Suyal
huggingface.co/adityasuyal


πŸ“„ License

MIT

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support