π§οΈ Weather Australia β Rain Predictor
A binary classification model that predicts whether it will rain tomorrow in Australia, trained on the classic weatherAUS dataset.
π Model Performance
| Metric | Score |
|---|---|
| Accuracy | see metrics.json |
| Precision | see metrics.json |
| Recall | see metrics.json |
| F1 Score | see metrics.json |
| ROC-AUC | see metrics.json |
β οΈ This is an imbalanced classification problem (~78% No Rain, ~22% Rain). F1 and ROC-AUC are more meaningful than accuracy alone. The model uses
class_weight="balanced"to handle this imbalance.
Confusion Matrix
ποΈ Dataset
- Source: weatherAUS.csv
- Rows: ~145,000 daily weather observations
- Coverage: 49 weather stations across Australia (2007β2017)
- Target:
RainTomorrowβ Yes (1) / No (0) - Processed data: amarshiv86/weather-aus-rain-dataset
Features Used (20 total)
Numeric (16)
| Feature | Description |
|---|---|
MinTemp |
Minimum temperature (Β°C) |
MaxTemp |
Maximum temperature (Β°C) |
Rainfall |
Rainfall today (mm) |
Evaporation |
Evaporation (mm) |
Sunshine |
Hours of bright sunshine |
WindGustSpeed |
Max wind gust speed (km/h) |
WindSpeed9am |
Wind speed at 9am (km/h) |
WindSpeed3pm |
Wind speed at 3pm (km/h) |
Humidity9am |
Relative humidity at 9am (%) |
Humidity3pm |
Relative humidity at 3pm (%) |
Pressure9am |
Atmospheric pressure at 9am (hPa) |
Pressure3pm |
Atmospheric pressure at 3pm (hPa) |
Cloud9am |
Cloud cover at 9am (oktas 0β8) |
Cloud3pm |
Cloud cover at 3pm (oktas 0β8) |
Temp9am |
Temperature at 9am (Β°C) |
Temp3pm |
Temperature at 3pm (Β°C) |
Categorical β label-encoded to integer (3)
| Feature | Description | Encoding |
|---|---|---|
WindGustDir |
Direction of strongest wind gust | N=0, NNE=1, β¦ NNW=15 |
WindDir9am |
Wind direction at 9am | N=0, NNE=1, β¦ NNW=15 |
WindDir3pm |
Wind direction at 3pm | N=0, NNE=1, β¦ NNW=15 |
Binary (1)
| Feature | Description | Encoding |
|---|---|---|
RainToday |
Did it rain today? | Yes=1, No=0 |
π€ Model Details
| Property | Value |
|---|---|
| Model Type | Pipeline(StandardScaler β RandomForestClassifier) |
| Library | scikit-learn |
| Class Weight | balanced (handles rain/no-rain imbalance) |
| Training Framework | MLflow |
| Pipeline | GitHub Actions (automated retraining) |
| Artifact Storage | Hugging Face Hub |
The model is wrapped in a scikit-learn Pipeline β raw feature values are passed directly with no manual scaling required.
π How to Use
import pickle
import numpy as np
from huggingface_hub import hf_hub_download
# Download model
model_path = hf_hub_download(
repo_id="amarshiv86/weather-aus-rain-model",
filename="models/model.pkl",
repo_type="model"
)
model = pickle.load(open(model_path, "rb"))
# Wind direction encoding
WIND_DIRS = ['N','NNE','NE','ENE','E','ESE','SE','SSE',
'S','SSW','SW','WSW','W','WNW','NW','NNW']
def wind_to_int(d): return WIND_DIRS.index(d.upper())
# Feature order must match exactly (20 features):
# Numeric (16) + Categorical encoded (3) + Binary (1)
sample = np.array([[
13.4, # MinTemp
22.9, # MaxTemp
0.6, # Rainfall
5.0, # Evaporation
7.5, # Sunshine
44.0, # WindGustSpeed
20.0, # WindSpeed9am
24.0, # WindSpeed3pm
71.0, # Humidity9am
22.0, # Humidity3pm
1007.7,# Pressure9am
1007.1,# Pressure3pm
4, # Cloud9am
5, # Cloud3pm
16.9, # Temp9am
21.8, # Temp3pm
wind_to_int('S'), # WindGustDir
wind_to_int('W'), # WindDir9am
wind_to_int('SW'), # WindDir3pm
0, # RainToday (0=No, 1=Yes)
]])
pred = model.predict(sample)[0]
prob = model.predict_proba(sample)[0][pred]
print(f"Rain Tomorrow: {'Yes' if pred == 1 else 'No'} (confidence: {prob:.1%})")
π MLOps Pipeline
This model is automatically retrained via GitHub Actions whenever:
- Raw data changes (
data/raw/weatherAUS.csv) - Source code changes (
src/) - Hyperparameters change (
params.yaml)
GitHub Push
β
GitHub Actions
β
prepare.py β train.py β evaluate.py
β β
model.pkl metrics.json
confusion_matrix.png
β
Hugging Face Hub (this repo)
β
HF Spaces β FastAPI live demo
π Repository Structure
amarshiv86/weather-aus-rain-model
βββ models/
β βββ model.pkl # sklearn Pipeline (scaler + RandomForest)
βββ artifacts/
β βββ confusion_matrix.png # latest evaluation plot
βββ metrics.json # latest evaluation metrics
π Live Demo
Try the model live via the FastAPI app hosted on HF Spaces: π amarshiv86/weather-aus-rain-api
π License
MIT β free to use, modify, and distribute.
