Downloads · 30 days
3
9% of all-time downloads
DanielTobi0/climate-rnn-model
climate-rnn-model is a machine learning model from DanielTobi0. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
LSTM-based time series forecasting model for next-day temperature prediction.
Downloads · 30 days
3
9% of all-time downloads
All-time downloads
33
Public
Repo size
460 KB
Likes
0
Public
Click a slice to open those files.
.bin459 KB · 99%
From the Hugging Face model README
LSTM-based time series forecasting model for next-day temperature prediction.
This model predicts the next day's temperature based on 30 days of historical climate data (temperature, humidity, wind speed, and atmospheric pressure). It was trained on the Daily Delhi Climate dataset using hyperparameter optimization with Ray Tune.
Architecture: LSTM (2 layers, 96 hidden units) Framework: PyTorch 2.12.0+cu130 Input: 30-day sequence of 4 climate features Output: Next-day temperature in Celsius
Evaluated on held-out test data (114 samples):
from huggingface_hub import hf_hub_download
import torch
import pickle
import json
import numpy as np
# Download model files
model_path = hf_hub_download("DanielTobi0/climate-rnn-model", "pytorch_model.bin")
scaler_path = hf_hub_download("DanielTobi0/climate-rnn-model", "scaler.pkl")
config_path = hf_hub_download("DanielTobi0/climate-rnn-model", "config.json")
# Load model architecture (you need the ClimateRNN class)
with open(config_path, 'r') as f:
config = json.load(f)
from src.model.architecture import ClimateRNN
model = ClimateRNN(
input_size=config['hyperparameters']['input_size'],
hidden_size=config['hyperparameters']['hidden_size'],
num_layers=config['hyperparameters']['num_layers'],
dropout=config['hyperparameters']['dropout']
)
# Load weights
model.load_state_dict(torch.load(model_path, map_location='cpu', weights_only=True))
model.eval()
# Load scaler
with open(scaler_path, 'rb') as f:
scaler = pickle.load(f)
# Prepare input (30-day sequence)
sequence = [
[25.0, 60.0, 5.0, 1010.0], # Day 1: [temp, humidity, wind_speed, pressure]
[26.0, 58.0, 6.0, 1012.0], # Day 2
# ... 28 more days
]
sequence_scaled = scaler.transform(sequence)
x = torch.tensor(sequence_scaled, dtype=torch.float32).unsqueeze(0)
# Predict
with torch.inference_mode():
prediction_scaled = model(x).item()
# Inverse transform (temperature is at index 0)
dummy = np.zeros((1, 4))
dummy[0, 0] = prediction_scaled
temperature = scaler.inverse_transform(dummy)[0, 0]
print(f"Predicted temperature: {temperature:.2f}°C")
Dataset: Daily Delhi Climate (2013-2017) Training samples: 1,170 Test samples: 114 Features: meantemp, humidity, wind_speed, meanpressure
Optimized using Ray Tune with ASHA scheduler:
MIT License