🌧️ 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

Confusion Matrix


πŸ—‚οΈ 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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Dataset used to train amarshiv86/weather-aus-rain-model

Space using amarshiv86/weather-aus-rain-model 1