DanielTobi0 commited on
Commit
1182cdd
·
verified ·
1 Parent(s): 69ce8a3

Upload climate forecasting RNN model

Browse files
Files changed (4) hide show
  1. README.md +120 -0
  2. config.json +61 -0
  3. pytorch_model.bin +3 -0
  4. scaler.pkl +3 -0
README.md ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ tags:
5
+ - climate
6
+ - time-series
7
+ - lstm
8
+ - temperature-forecasting
9
+ - pytorch
10
+ datasets:
11
+ - delhi-climate
12
+ metrics:
13
+ - mae
14
+ - rmse
15
+ ---
16
+
17
+ # Climate Forecasting RNN
18
+
19
+ LSTM-based time series forecasting model for next-day temperature prediction.
20
+
21
+ ## Model Description
22
+
23
+ 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.
24
+
25
+ **Architecture**: LSTM (2 layers, 96 hidden units)
26
+ **Framework**: PyTorch 2.12.0+cu130
27
+ **Input**: 30-day sequence of 4 climate features
28
+ **Output**: Next-day temperature in Celsius
29
+
30
+ ## Performance
31
+
32
+ Evaluated on held-out test data (114 samples):
33
+
34
+ - **MAE**: 1.930°C
35
+ - **RMSE**: 2.422°C
36
+ - **Validation MSE**: 0.007749
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ from huggingface_hub import hf_hub_download
42
+ import torch
43
+ import pickle
44
+ import json
45
+ import numpy as np
46
+
47
+ # Download model files
48
+ model_path = hf_hub_download("DanielTobi0/climate-rnn-model", "pytorch_model.bin")
49
+ scaler_path = hf_hub_download("DanielTobi0/climate-rnn-model", "scaler.pkl")
50
+ config_path = hf_hub_download("DanielTobi0/climate-rnn-model", "config.json")
51
+
52
+ # Load model architecture (you need the ClimateRNN class)
53
+ with open(config_path, 'r') as f:
54
+ config = json.load(f)
55
+
56
+ from src.model.architecture import ClimateRNN
57
+
58
+ model = ClimateRNN(
59
+ input_size=config['hyperparameters']['input_size'],
60
+ hidden_size=config['hyperparameters']['hidden_size'],
61
+ num_layers=config['hyperparameters']['num_layers'],
62
+ dropout=config['hyperparameters']['dropout']
63
+ )
64
+
65
+ # Load weights
66
+ model.load_state_dict(torch.load(model_path, map_location='cpu', weights_only=True))
67
+ model.eval()
68
+
69
+ # Load scaler
70
+ with open(scaler_path, 'rb') as f:
71
+ scaler = pickle.load(f)
72
+
73
+ # Prepare input (30-day sequence)
74
+ sequence = [
75
+ [25.0, 60.0, 5.0, 1010.0], # Day 1: [temp, humidity, wind_speed, pressure]
76
+ [26.0, 58.0, 6.0, 1012.0], # Day 2
77
+ # ... 28 more days
78
+ ]
79
+ sequence_scaled = scaler.transform(sequence)
80
+ x = torch.tensor(sequence_scaled, dtype=torch.float32).unsqueeze(0)
81
+
82
+ # Predict
83
+ with torch.inference_mode():
84
+ prediction_scaled = model(x).item()
85
+
86
+ # Inverse transform (temperature is at index 0)
87
+ dummy = np.zeros((1, 4))
88
+ dummy[0, 0] = prediction_scaled
89
+ temperature = scaler.inverse_transform(dummy)[0, 0]
90
+ print(f"Predicted temperature: {temperature:.2f}°C")
91
+ ```
92
+
93
+ ## Training Data
94
+
95
+ **Dataset**: Daily Delhi Climate (2013-2017)
96
+ **Training samples**: 1,170
97
+ **Test samples**: 114
98
+ **Features**: meantemp, humidity, wind_speed, meanpressure
99
+
100
+ ## Hyperparameters
101
+
102
+ Optimized using Ray Tune with ASHA scheduler:
103
+
104
+ - Hidden size: 96
105
+ - Num layers: 2
106
+ - Dropout: 0.1003
107
+ - Sequence length: 30 days
108
+ - Learning rate: 0.000374
109
+ - Batch size: 32
110
+
111
+ ## Limitations
112
+
113
+ - Trained only on Delhi climate data (may not generalize to other regions)
114
+ - Requires exactly 30 consecutive days of input
115
+ - Predicts only one day ahead
116
+ - Does not account for extreme weather events or climate change trends
117
+
118
+ ## License
119
+
120
+ MIT License
config.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "ClimateRNN",
3
+ "architecture": "LSTM",
4
+ "framework": "PyTorch",
5
+ "version": "1.0.0",
6
+ "hyperparameters": {
7
+ "input_size": 4,
8
+ "hidden_size": 96,
9
+ "num_layers": 2,
10
+ "dropout": 0.10027879545211107,
11
+ "seq_length": 30,
12
+ "learning_rate": 0.00037446563861783026,
13
+ "batch_size": 32,
14
+ "grad_clip_max_norm": 1.0
15
+ },
16
+ "features": {
17
+ "input_features": [
18
+ "meantemp",
19
+ "humidity",
20
+ "wind_speed",
21
+ "meanpressure"
22
+ ],
23
+ "target_feature": "meantemp",
24
+ "target_idx": 0,
25
+ "feature_order": "Features must be provided in exact order: meantemp, humidity, wind_speed, meanpressure"
26
+ },
27
+ "preprocessing": {
28
+ "scaler": "MinMaxScaler",
29
+ "fit_on": "training_data",
30
+ "scaler_file": "scaler.pkl"
31
+ },
32
+ "performance": {
33
+ "test_mae": 1.93,
34
+ "test_rmse": 2.422,
35
+ "validation_mse": 0.007749,
36
+ "unit": "celsius"
37
+ },
38
+ "training": {
39
+ "dataset": "Daily Delhi Climate",
40
+ "training_samples": 1170,
41
+ "validation_samples": 292,
42
+ "test_samples": 114,
43
+ "training_date_range": "2013-01-01 00:00:00 to 2017-01-01 00:00:00",
44
+ "test_date_range": "2017-01-01 00:00:00 to 2017-04-24 00:00:00",
45
+ "optimizer": "Adam",
46
+ "scheduler": "ReduceLROnPlateau",
47
+ "epochs": 50
48
+ },
49
+ "inference": {
50
+ "input_format": "30-day sequence of 4 climate features",
51
+ "output_format": "Next-day temperature prediction in Celsius",
52
+ "device": "cpu",
53
+ "expected_latency_ms": 20
54
+ },
55
+ "metadata": {
56
+ "created_at": "2026-05-15",
57
+ "pytorch_version": "2.12.0+cu130",
58
+ "python_version": "3.11+",
59
+ "license": "MIT"
60
+ }
61
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:318cae558b341f658205ba4c1cb108f11bcb2da45db9ff2c32c85466acc4f818
3
+ size 459141
scaler.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e153afde608b6855120ec3b903df6ffcf7ed19fafcdbeab9c71d79f9cc2d1914
3
+ size 792