Reinforcement Learning
stable-baselines3
deep-reinforcement-learning
agricultural-ai
weather-modelling
curriculum-learning
edge-ai
Instructions to use DHDRL/monsoon-rl with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- stable-baselines3
How to use DHDRL/monsoon-rl with stable-baselines3:
from huggingface_sb3 import load_from_hub checkpoint = load_from_hub( repo_id="DHDRL/monsoon-rl", filename="{MODEL FILENAME}.zip", ) - Notebooks
- Google Colab
- Kaggle
Update timesfm_wrapper.py
Browse files- timesfm_wrapper.py +1 -33
timesfm_wrapper.py
CHANGED
|
@@ -78,13 +78,6 @@ def _rh_to_prob_humidity(rh_max_pct: float) -> float:
|
|
| 78 |
# ---------------------------------------------------------------------------
|
| 79 |
|
| 80 |
class BaselineBackend:
|
| 81 |
-
"""
|
| 82 |
-
Deterministic statistical forecast derived entirely from ZoneObs fields.
|
| 83 |
-
|
| 84 |
-
No randomness — deterministic forecasts let the policy learn stable
|
| 85 |
-
input-output mappings. Stochasticity enters through the observation
|
| 86 |
-
pipeline, not the forecast.
|
| 87 |
-
"""
|
| 88 |
|
| 89 |
def __init__(self, horizon_days: int = 30) -> None:
|
| 90 |
self.horizon_days = horizon_days
|
|
@@ -136,18 +129,6 @@ class BaselineBackend:
|
|
| 136 |
# ---------------------------------------------------------------------------
|
| 137 |
|
| 138 |
class OpenMeteoBackend:
|
| 139 |
-
"""
|
| 140 |
-
Real probabilistic forecast via Open-Meteo free API.
|
| 141 |
-
|
| 142 |
-
FIX vs original: lat/lon moved from forecast() into __init__() so the
|
| 143 |
-
object satisfies the ForecastBackend Protocol (forecast(self, obs) only).
|
| 144 |
-
Resolve lat/lon from the zone registry before constructing this object.
|
| 145 |
-
|
| 146 |
-
Example:
|
| 147 |
-
lat, lon = zone_registry[zone_id].centroid
|
| 148 |
-
backend = OpenMeteoBackend(lat=lat, lon=lon, horizon_days=16)
|
| 149 |
-
result = backend.forecast(obs)
|
| 150 |
-
"""
|
| 151 |
|
| 152 |
BASE_URL = "https://api.open-meteo.com/v1/forecast"
|
| 153 |
TIMEOUT_S = 15
|
|
@@ -256,12 +237,6 @@ class OpenMeteoBackend:
|
|
| 256 |
|
| 257 |
@dataclass
|
| 258 |
class LocalTimesFMBackend:
|
| 259 |
-
"""
|
| 260 |
-
Local TimesFM-2.5-200m inference. SHA256-verified. No synthetic fallback.
|
| 261 |
-
|
| 262 |
-
Download checkpoint from:
|
| 263 |
-
https://huggingface.co/google/timesfm-2.5-200m-pytorch
|
| 264 |
-
"""
|
| 265 |
|
| 266 |
checkpoint_path: Path
|
| 267 |
expected_sha256: str
|
|
@@ -402,13 +377,6 @@ def create_forecast_backend(
|
|
| 402 |
lat: Optional[float] = None,
|
| 403 |
lon: Optional[float] = None,
|
| 404 |
) -> ForecastBackend:
|
| 405 |
-
"""
|
| 406 |
-
Create a ForecastBackend.
|
| 407 |
-
|
| 408 |
-
mode="baseline" — deterministic statistical forecast (default, no deps)
|
| 409 |
-
mode="openmeteo" — real Open-Meteo API forecast (requires requests, lat, lon)
|
| 410 |
-
mode="timesfm" — local TimesFM inference (requires checkpoint + timesfm)
|
| 411 |
-
"""
|
| 412 |
if mode == "baseline":
|
| 413 |
return BaselineBackend(horizon_days=horizon_days)
|
| 414 |
|
|
@@ -439,4 +407,4 @@ def create_forecast_backend(
|
|
| 439 |
|
| 440 |
raise ValueError(
|
| 441 |
f"Unknown backend mode: '{mode}'. Valid: 'baseline', 'openmeteo', 'timesfm'"
|
| 442 |
-
)
|
|
|
|
| 78 |
# ---------------------------------------------------------------------------
|
| 79 |
|
| 80 |
class BaselineBackend:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
def __init__(self, horizon_days: int = 30) -> None:
|
| 83 |
self.horizon_days = horizon_days
|
|
|
|
| 129 |
# ---------------------------------------------------------------------------
|
| 130 |
|
| 131 |
class OpenMeteoBackend:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
BASE_URL = "https://api.open-meteo.com/v1/forecast"
|
| 134 |
TIMEOUT_S = 15
|
|
|
|
| 237 |
|
| 238 |
@dataclass
|
| 239 |
class LocalTimesFMBackend:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
checkpoint_path: Path
|
| 242 |
expected_sha256: str
|
|
|
|
| 377 |
lat: Optional[float] = None,
|
| 378 |
lon: Optional[float] = None,
|
| 379 |
) -> ForecastBackend:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
if mode == "baseline":
|
| 381 |
return BaselineBackend(horizon_days=horizon_days)
|
| 382 |
|
|
|
|
| 407 |
|
| 408 |
raise ValueError(
|
| 409 |
f"Unknown backend mode: '{mode}'. Valid: 'baseline', 'openmeteo', 'timesfm'"
|
| 410 |
+
)
|